Big numbers break underscore.js _.contains Big numbers break underscore.js _.contains mongoose mongoose

Big numbers break underscore.js _.contains


The last returns "3e+23" which is not equals to "300000000000000000000002"


The problem was always that I get an input String which is automatically converted to a number (by a library). So I only had to make the 'foreign key' a smaller number. I eventually created a custom number autogenerate function to circumvent this problem:

var autoIncrement = require('mongoose-auto-increment');var address = require('./Address');var connection = mongoose.createConnection(address.mongo());autoIncrement.initialize(connection);var UserSchema = new mongoose.Schema({ /* property definitions */});mongoose.model('User', UserSchema);UserSchema.plugin(autoIncrement.plugin, {    model: 'User',    startAt: 10000001});

As a result, I had to change the referencing mechanism:

var GroupSchema = new mongoose.Schema({    users: [{type: Number, ref: 'User'}],    /* other property definitions */});