mirror of
https://github.com/arnaucube/thoughts.git
synced 2026-02-07 19:56:48 +01:00
database externa
This commit is contained in:
27
node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js
generated
vendored
Normal file
27
node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js
generated
vendored
Normal file
@@ -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);
|
||||
9
node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json
generated
vendored
Normal file
9
node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"count": "number",
|
||||
"unit": "number",
|
||||
"description": "string",
|
||||
"links": ["string"],
|
||||
"created": "date",
|
||||
"additive": "boolean",
|
||||
"user_id": "ObjectId"
|
||||
}
|
||||
Reference in New Issue
Block a user