This file contains hidden or 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
| var mongoose = require('./mongoose'); | |
| console.error(mongoose.version); | |
| function dateValueOf (d) { | |
| console.error('date valueOf ran'); | |
| return d.valueOf(); | |
| } | |
| var S = new mongoose.Schema({ |
This file contains hidden or 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
| var mongoose = require('./mongoose'); | |
| console.error(mongoose.version); | |
| mongoose.connect('localhost', 'datevalueof'); | |
| function dateValueOf (d) { | |
| console.error('date valueOf ran'); | |
| return d.valueOf(); | |
| } |
This file contains hidden or 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
| var maSchema = new Schema({ | |
| name: { type: String, default: 'nameless' } | |
| , age: { type: Number, default: function () { return 0 }} | |
| }); | |
| var M = mongoose.model('M', maSchema); | |
| // populate some data ... | |
| M.findOne({..}, { age: 1 }, function (err, m) { |
This file contains hidden or 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
| var mongoose = require('./mongoose'); | |
| mongoose.connect('localhost', 'testing_516'); | |
| var ASchema = new mongoose.Schema({ 0: Number, 1: Number }); | |
| var A = mongoose.model('A', ASchema); | |
| mongoose.connection.on('open', function () { | |
| var a = new A; |
This file contains hidden or 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
| var db = start(); | |
| var schema = new Schema({ s: [String] }); | |
| var S = db.model('arrayWithUndefined', schema); | |
| var s = new S({ s: ['hi', undefined] }); // no error | |
| console.error(s.s); // [] | |
| console.error(s._saveError.message); // Cast to non_object_property_load failed for value "hi," |
This file contains hidden or 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
| var mongoose = require('mongoose'); | |
| mongoose.connect('localhost', 'testing_535'); | |
| console.error('mongoose version', mongoose.version); | |
| var OID = mongoose.Types.ObjectId; | |
| var ASchema = new mongoose.Schema({ | |
| square: mongoose.Schema.ObjectId | |
| , task: Number |
This file contains hidden or 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
| lbrset:SECONDARY> db.users.findOne({'contact.email': "[email protected]" }) | |
| { | |
| "_id" : ObjectId("4e6f6ea583e3f9d525028f40"), | |
| "account" : { | |
| "created_at" : ISODate("2011-09-13T14:54:29.025Z"), | |
| "inmailchimp" : true, | |
| "loggedin_at" : ISODate("2011-09-26T15:02:45.858Z"), | |
| "password" : "9a5626a81b11ae7de748d5e3669278f4", | |
| "role" : "teacher", | |
| "roles" : [ ], |
This file contains hidden or 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
| lbrset:SECONDARY> db.studentprofiles.findOne({'access.role':'parent', 'access.id':'4e66c586a099f32d30001ffa' }) | |
| { | |
| "_id" : ObjectId("4e62f48b27e3f458430072f2"), | |
| "access" : [ | |
| { | |
| "id" : "4e66c586a099f32d30001ffa", | |
| "classid" : "4e62f32c27e3f4584300714f", | |
| "role" : "parent", | |
| "_id" : ObjectId("4e66c586a099f32d30001ffb") | |
| }, |
This file contains hidden or 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
| var Long = require('../goog/math/long').Long, | |
| debug = require('util').debug, | |
| inspect = require('util').inspect; | |
| /** | |
| Reply message from mongo db | |
| **/ | |
| var MongoReply = exports.MongoReply = function(db, binary_reply) { | |
| try { | |
| this.documents = []; |
This file contains hidden or 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
| // Catch error and log | |
| try { | |
| // Parse the data as a reply object | |
| reply = new MongoReply(parent, message); | |
| } catch(err) { | |
| var errObj = {err:"unparsable", bin:message, parseState:err}; | |
| server.logger.error("mongoreplyParserError", errObj); | |
| return parent.emit("error", errObj); | |
| } |