Using bitwise operation for request in mongodb

I need to make a query like this in MongoDB:

db.collection.find( { $where : "(this.type & some_num) ^ some_num == 0"} ) 

Some_num is a variable and can be any integer.

I read the document here that says the Javascript query is slowing down and also cannot use the index and requires a table scan.

What is the alternative to the above query?

+4
source share
3 answers

, Mongo, - , , . .

+1
+1

, . Construct this.type JS, , . - . , , xoring .

, - .

Anyway, you can use the bitwise xor operator in mognodb 2.6, or you can try the experimental version 2.5 now.

0
source

All Articles