Frage

I'm continuing practicing with LiveCode and MongoDB. I made a stack with a button with a script connecting to my local MongoDB instance. This script "builds" a query. When my code produces this:

C:\mongodb\bin\mongo.exe localhost:27017/BatGar --eval "var c=db.BatRegis.find(); while(c.hasNext()) printjson(c.next())"

I get documents from the server.

But when my code produces:

C:\mongodb\bin\mongo.exe localhost:27017/BatGar --eval "var c=db.BatRegis.find({"inspec":"No"}); while(c.hasNext()) printjson(c.next())"

or

C:\mongodb\bin\mongo.exe localhost:27017/BatGar --eval "var c=db.BatRegis.find({inspec:"No"}); while(c.hasNext()) printjson(c.next())"

I get error:

MongoDB shell version: 2.2.7
connecting to: localhost:27017/BatGar
Thu Apr 03 20:35:30 ReferenceError: No is not defined (shell eval):1

Any ideas?

War es hilfreich?

Lösung

Use curly quotes or single quotes:

C:\mongodb\bin\mongo.exe localhost:27017/BatGar --eval "var c=db.BatRegis.find({inspec:`No`}); while(c.hasNext()) printjson(c.next())"

or

C:\mongodb\bin\mongo.exe localhost:27017/BatGar --eval "var c=db.BatRegis.find({inspec'No'}); while(c.hasNext()) printjson(c.next())"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top