×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Adam Bedell
Added: Aug 3, 2013 11:17 PM
Views: 25
This is from the posts @ http://thecodebarbarian.wordpress.com/
  1. var Mongoose = require('mongoose');
  2. var myConnection = Mongoose.createConnection('localhost', 'mydatabase');
  3.  
  4. var MySchema = new Mongoose.schema({
name : {
  5.     type : String,
  6.     default : 'Val',
  7.     enum : ['Val', 'Valeri', 'Valeri Karpov']
  8.   },
  9. created : {
  10.     type : Date,
  11.     default : Date.now
  12.   }
  13. });var MyModel = myConnection.model('mycollection', MySchema);
  14. var myDocument = new MyModel({});
  15.