Created
November 1, 2013 09:56
-
-
Save mwmaleks/7263255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by mwmaleks on 31.10.13. | |
*/ | |
var mongoose = require('mongoose'); | |
console.log('Версия монгус -', mongoose.version ); | |
var db = mongoose.createConnection('mongodb://localhost/learn'); | |
db.on("error", console.error.bind(console, 'connection error:' )); | |
//db.once("open", function callback () { | |
// console.log('Connected!') | |
//}); | |
var UnicornsSchema = mongoose.Schema({ | |
name: {type: String}, | |
dob: {type: Date}, | |
loves: {type: Array}, | |
weight: {type: Number}, | |
gender: {type: String}, | |
vampires: {type: Number} | |
}); | |
var unicorns = db.model('unicorns', UnicornsSchema ); | |
//unicorns.find({name: 'Leia'}, 'weight', function (err, result) { | |
// if (err) return handleError(err); | |
// console.log(result); | |
//}); | |
var uni = new unicorns({ | |
_id:'000000000000000000000004', | |
name: 'Lina', | |
dob: new Date(1993, 5, 3, 11, 53, 0), | |
loves: ['bananas', 'passion'], | |
weight: 650, | |
gender: 'f', | |
vampires: 12 | |
}); | |
console.log(uni); | |
uni.save(function () { | |
}); | |
unicorns.find({$or: [{loves: 'passion' }, {loves: 'bananas'}]}, function (err, result) { | |
console.log(result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment