Anouar Anouar - 4 months ago 11
Node.js Question

Marklogic|NodeJS API - Query on a specific categorie "properties"

I have a json document in my DB that looks like this :

{
"uri" : "/me/myself/and/bd1e0f91656bfc713eb6560eeaad7ad1.json",
"category" : "content",
"format" : "json",
"versionId" : "14697362595356370",
"contentType" : "application/json",
"contentLength" : "1938",
"collections" : ["http://me.myself.com/collectionA"],
"properties" : {
"relatives" : ["/me/myself/and/B.json", "/me/myself/and/A.json"]
},
"content":{}


}

I'm trying to get all documents that have a specific relative in the properties:

qb.where(
qb.scope(
qb.property('relatives'),
qb.word("/me/myself/and/B.json"),
qb.fragmentScope('properties')
))


But i keep getting a large set of document that doesn't fit the query.

Any idea how to do this using the Marklogic NodeJS API?

Answer
qb.where(
  qb.propertiesFragment(
    qb.term('/me/myself/and/B.json')
  )
)

This worked for me.