The MongoDB collection "test" contains the entry:
{ "_id" : ObjectId("56f53cded3095c203024a884"), status : 0 }
I connected to mongo using Node.js (Mongoose driver). Define a schema for this collection:
"Test" : {
status : { type : Number, default : 0 }
}
The "status" field is a binary flag, should contain only 0 or 1 value. I want to change this flag with an update request:
test.update( { 'status' : 0 }, { $bit : { 'status' : { xor : NumberInt(1) } } }, function( err, result ) {
if( err ) {
console.log( 'err' );
}
});
Mongoose not found NumberInt()function:
ReferenceError: NumberInt is not defined
When I put the prime number โ1โ without a function NumberInt(), I have no changes or errors.
In the MongoDB query, this query worked perfectly. How can I work with NumberInt()in the Mongoose driver? Does he have a different name?
source
share