如果我这样创建TAFFYDB数据库:
import React, { Component } from 'react';
import axios from 'axios';
class App extends Component {
state = {
fragrances: []
}
componentDidMount() {
axios.get('http://localhost:1337/fragrances')
.then(res => {
const fragrances = res.data;
this.setState({ fragrances });
})
}
render() {
const { fragrances } = this.state;
return (
<div>
{
fragrances.map((fragrance, index) => {
<h2>{fragrance.Name}</h2>
console.log(fragrance);
})
}
</div>
);
}
}
export default App;
我可以按每个术语查询,例如客户名称:
customerDB.insert({
"custID":"JONMI",
"custName": "MIKE JONES",
"custCity": "CHICAGO"
});
但是有没有一种方法可以在单个查询中按任何术语进行搜索? 就是说,如果我通过MIKE,CHICAGO或JONMI搜索,它将找到一个匹配项。
答案 0 :(得分:0)
来自TaffyDB documentation:
customerDB([ {"custName":{likenocase:request.term}},
{"custCity":{likenocase:request.term}},
{"custID":{likenocase:request.term}} ]
).each(function (record,recordnumber) {
这就像逻辑上的“ OR”一样