2

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

4
  • 3
    Found! BasicDBObject query = new BasicDBObject(); query.append("$where", new Code("function() {return /.*11/.test(this.foglio) || /.*99/.test(this.comune)}")); Commented Mar 22, 2012 at 14:39
  • can you explain more? where is Code defined? Commented Mar 27, 2012 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. Commented Apr 3, 2012 at 13:44
  • 1
    Did that work for you devmao? Can you post it as an answer and then accept it youself? Thanks. Commented May 29, 2012 at 13:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.