Create a gist now

Instantly share code, notes, and snippets.

mongoose number subclass fail
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var schema = new Schema({
n1: Number
, n2: Number
});
var A = mongoose.model('A', schema);
var n = 5;
var a = new A({ n1: n, n2: n });
console.log(typeof a.n1, typeof n) // object, number
console.log(n == a.n1, a.n1 == a.n2); // true, false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment