Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to convert this query in java:

db.beni.find({ $where: function() {
  return /.*11/.test(this.foglio) || /.*99/.test(this.comune) } })

Where this.foglio is a numeric field and this.comune is a string fields.

Thanks

share|improve this question
2  
Found! BasicDBObject query = new BasicDBObject(); query.append("$where", new Code("function() {return /.*11/.test(this.foglio) || /.*99/.test(this.comune)}")); – devmao Mar 22 '12 at 14:39
can you explain more? where is Code defined? – Amitabh Mar 27 '12 at 20:04
1  
simply with the code class (api.mongodb.org/java/current/org/bson/types/Code.html) you are able to use the above js syntax with the java driver. – devmao Apr 3 '12 at 13:44
1  
Did that work for you devmao? Can you post it as an answer and then accept it youself? Thanks. – Zecas May 29 '12 at 13:52

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.