使用 feathers-vuex 搜索嵌套对象需要模糊搜索吗?
Fuzzy search required for searching nested objects using feathers-vuex?
我在项目中使用feathers-vuex,对feathers包的其余部分不是很熟悉。我正在使用它是因为有了脚手架 cli,它很容易上手并且可以正常工作。到目前为止,这是一次非常好的体验。然而,这也意味着我并不完全了解引擎盖下发生的事情。我正在尝试使用 find 函数检索嵌套数组包含 mongodb 中的特定字符串的所有记录。题目如下:
- 到目前为止,我能想到的唯一选择是模糊搜索。这是这样做的方法吗?或者还有其他的可能吗?
- 我关于模糊搜索因缺少 hook 而无法工作的假设是否正确?还是我误读了文档?
- 还有其他通用方法可以实现吗?
- 这是否意味着模糊搜索将无法使用 feathers-vuex 工作,或者有什么方法可以实现吗?
既然你已经设置好了,我建议你完成 basics guide and have a look at any of the other guides。
根据您选择的内容,您还可以查看 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。
如果您查看 MongoDB documentation on how to query for arrays,您会发现查询数组中的值的方式与此类似:
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();
我在项目中使用feathers-vuex,对feathers包的其余部分不是很熟悉。我正在使用它是因为有了脚手架 cli,它很容易上手并且可以正常工作。到目前为止,这是一次非常好的体验。然而,这也意味着我并不完全了解引擎盖下发生的事情。我正在尝试使用 find 函数检索嵌套数组包含 mongodb 中的特定字符串的所有记录。题目如下:
- 到目前为止,我能想到的唯一选择是模糊搜索。这是这样做的方法吗?或者还有其他的可能吗?
- 我关于模糊搜索因缺少 hook 而无法工作的假设是否正确?还是我误读了文档?
- 还有其他通用方法可以实现吗?
- 这是否意味着模糊搜索将无法使用 feathers-vuex 工作,或者有什么方法可以实现吗?
既然你已经设置好了,我建议你完成 basics guide and have a look at any of the other guides。
根据您选择的内容,您还可以查看 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。
如果您查看 MongoDB documentation on how to query for arrays,您会发现查询数组中的值的方式与此类似:
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();