RejectedSoftware Forums

Sign up

Wrapping ObjectId() in mongo query

Hello,

Im trying to use "$ne" to excluded a specific "_id" in a query:

{ "$or": [ { "name":"josh", "_id": { "$ne": "blahblah" }  }, { "humor":"none", "_id": { "$ne": "blahblah" } } ] }

This however will not work since i need to wrap the "_id" string with ObjectId:

{ "$or": [ { "name":"josh", "_id": { "$ne": ObjectId("blahblah") } }, { "humor":"none", "_id": { "$ne": ObjectId("blahblah") } } ] }

Im not sure how to represent ObjectId("string") on the D side. Any ideas?

Thanks,
Josh

Re: Wrapping ObjectId() in mongo query

On Thu, 19 Sep 2013 21:06:46 GMT, Joshua Niehus wrote:

Im not sure how to represent ObjectId("string") on the D side. Any ideas?

Thanks,
Josh

Whoops, found what I was doing wrong. I was re-serializing back to Json after setting "id" to BsonObjectID.fromString(data["id"])