0

I want to use a MySQL database to manage a collection of documents in JSON format. Let's say each document has this structure:

{ 
  "firstname":"John",
  "lastname":"Smith",
  "books":[
    { "title":"Dune", "author":"Frank Herbert" },
    { "title":"Fahrenheit 451", "author":"Ray Bradbury" }
  ]
}

How would I use X DevAPI to find documents where the "books" array contains a specific title?

1 Answer 1

0

You can use a SearchConditionStr containing a documentPathLastItem expression in form of <the_title> in $.books[*].title (the leading $. should be optional), which depending on the language you are using will end up being something like:

collection.find(':name in books[*].title')
  .bind('name', '<the_title>')
  .execute()

Disclaimer: I'm the lead developer of the MySQL X DevAPI Connector for Node.js

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.