public
Created

mongoose number subclass fail

  • Download Gist
mongoosenumbersubclass.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.