PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 27 lines | 15 code | 6 blank | 6 comment | 0 complexity | 5ee376f30af348ae58961a71d2d0bf9b MD5 | raw file
 1
 2// modules
 3var mongoose = require('../../../lib');
 4var Schema = mongoose.Schema;
 5
 6// parse json
 7var raw = require('./schema.json');
 8
 9// create a schema
10var timeSignatureSchema = Schema(raw);
11
12// compile the model
13var TimeSignature = mongoose.model('TimeSignatures', timeSignatureSchema);
14
15// create a TimeSignature document
16var threeFour = new TimeSignature({
17  count: 3,
18  unit: 4,
19  description: '3/4',
20  additive: false,
21  created: new Date,
22  links: ['http://en.wikipedia.org/wiki/Time_signature'],
23  user_id: '518d31a0ef32bbfa853a9814'
24});
25
26// print its description
27console.log(threeFour);