summaryrefslogtreecommitdiffstats
path: root/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js
blob: 284b478d4c8e8b70a2a62c857fafde181eb2cfaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);