Am 05.01.2015 um 04:59 schrieb Yanni Chiu <yanni@rogers.com>:
On Jan 4, 2015, at 4:38 AM, Norbert Hartl <norbert@hartl.name> wrote:
someCollection select: { '$or' -> { { 'name' -> { '$regex' -> 'test' . '$options' -> 'i' } asDictionary } asDictionary. { 'description' -> { '$regex' -> 'test' . '$options' -> 'i' } asDictionary } asDictionary } } asDictionary
That worked. I was close, but I was using $or: instead of $or, and I was missing one level of asDictionary.
Just for the archive, thereâs one more query I needed, which was to find an object based on itâs object id. I ended up using:
voyageId := Integer readFrom: (request at: #voyageId) base: 16. someModel := SomeModel selectOne: { '_id' -> (OID value: voyageId) } asDictionary.
This is a web app using Teapot and Mustache, so I write the voyageId out using:
self voyageId value printStringHex
Sounds cool. If you have anything to publish I'm interested what you've done. Especially if you have some nice tricks doing form handling in teapot. Btw. for the archive. A common use case I encounter is to query objects that are being referenced by another object. It works like this AnyClass>>#referencedBy: anObject ^ AnyClass selectMany: { 'reference.__id' -> anObject voyageId } asDictionary Norbert