summaryrefslogtreecommitdiffstats
path: root/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json')
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json9
2 files changed, 36 insertions, 0 deletions
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js
new file mode 100644
index 0000000..284b478
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js
@@ -0,0 +1,27 @@
+
+// modules
+var mongoose = require('../../../lib');
+var Schema = mongoose.Schema;
+
+// parse json
+var raw = require('./schema.json');
+
+// create a schema
+var timeSignatureSchema = Schema(raw);
+
+// compile the model
+var TimeSignature = mongoose.model('TimeSignatures', timeSignatureSchema);
+
+// create a TimeSignature document
+var threeFour = new TimeSignature({
+ count: 3,
+ unit: 4,
+ description: '3/4',
+ additive: false,
+ created: new Date,
+ links: ['http://en.wikipedia.org/wiki/Time_signature'],
+ user_id: '518d31a0ef32bbfa853a9814'
+});
+
+// print its description
+console.log(threeFour);
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json
new file mode 100644
index 0000000..5afc626
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json
@@ -0,0 +1,9 @@
+{
+ "count": "number",
+ "unit": "number",
+ "description": "string",
+ "links": ["string"],
+ "created": "date",
+ "additive": "boolean",
+ "user_id": "ObjectId"
+}