Instantly share code, notes, and snippets.

What would you like to do?
mongoose number subclass fail
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log(' mongoose version: %s', mongoose.version);
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