Question

As an example, I have a document with nested custom metadata like:

owner: {"id":"12345"}

I've tried to find this document with:

docpad.getCollection("documents").findAll({
    "owner.id": "12345"
});

but to no avail.

What have I done wrong?

Était-ce utile?

La solution

Nested queries aren't supported by default, as it is a tricky thing to do.

For now, you should be able to do this:

CoffeeScript:

docpad.getCollection("documents").findAll({
    "owner": ({id}) -> id is "12345"
})

JavaScript:

docpad.getCollection("documents").findAll({
    "owner": function(model){ return model.id === "12345" }
})
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top