I am using feathers-vuex in a project and am not very familiar with the rest of the feathers package. I am using this is because with the scaffolding cli, it was very easy to get started and it just works. Has been a really good experience so far. However, this also means that I do not entirely get what's going on under the hood. I am trying to use the find function to retrieve all records where a nested array contains a certain string from a mongodb. The questions are as follows:
Now that you got set up, I do recommend to go through the basics guide and have a look at any of the other guides.
Depending on what you picked you can also look at the MongoDB and Mongoose database adapter API documentation. Additionally to the common query syntax both those adapters also support additional MongoDB queries which you can find in the MongoDB documentation.
If you look at the MongoDB documentation on how to query for arrays you can see that querying for a value in an array can be done similar to this:
async function run() {
await app.service('myservice').create({
name: 'first',
test: [ 'one', 'two' ]
});
await app.service('myservice').create({
name: 'second',
test: [ 'two', 'three' ]
});
let results = await app.service('myservice').find({
query: { test: 'two' }
});
console.log(results) // will log `first` and `second`
result = await app.service('myservice').find({
query: { test: 'one' }
});
console.log(results) // will log only `first`
}
run();