Import everything.
One of main advantage of a schema-less database is that you have not a schema.
Smart Sites database can host almost every collection you may need in your site generation procedures.
To import data or custom data into Smart Sites database you have to run SmartSiteLib application with –import parameter.
For example:
java -jar "SmartSiteLib.jar" --import
Optionally you can specify one more parameter, the name of file you want load:
java -jar "SmartSiteLib.jar" --import myfile.csv
Or, if you want load file with absolute path:
java -jar "SmartSiteLib.jar" --import c:/myfile.csv
How does –import works?
The –import parameter workflow is:
- –import checks if file path is present
- if no path is present, all content into “/import” folder will be processed and imported
- if path is present, path is checked for “relative” or “absolute” notation
- relative path (i.e. “myfile.csv”) are concatenated with absolute “/import” path to obtain an absolute path notation (i.e. “c:/…/import/myfile.csv”)
- absolute file path is processed and content of file is imported
Importing Data
Importing Data into Smart Sites Database means that you can import data in existing collections (sites, templates, items) overwriting existents or into new collections creating from scratch.
Before starting to import data consider following rules:
- The importer uses file name (without extension) as collection name. i.e. “items.csv” will be imported into items collection.
- The importer append data to existing collection or overwrite existing data if _id primary key exists and match current data. If you are importing data without _id field, a new one will be automatically created.
- If a collection does not exists, new one is created from scratch. i.e. “mycollection.csv” creates new collection named “mycollection”.
Accessing Data
Custom Data (and also standard one) are accessible in two main ways:
- Through $db reference. i.e. $db.find(“mycollection”)
- Declaring a template behavior. i.e. “mycollection.REPEAT:class1=SPIRAL.uid”
see also: Exporting Data