提交 033bfb35 编写于 作者: 雪洛's avatar 雪洛

docs: uniCloud

上级 4e8aaa0b
......@@ -270,6 +270,64 @@ db.collection('user').where({
name: new RegExp('^ABC')
})
```
**按照数组内的值查询**
mongoDB内按照数组内的值查询可以使用多种写法,以下面的数据为例
```js
{
arr:[{
name: 'item-1',
},{
name: 'item-2',
}]
}
{
arr:[{
name: 'item-3',
},{
name: 'item-4',
}]
}
```
如果想查询arr内第一个元素的name为item-1的记录可以使用如下写法
```js
const res = await db.collection('test').where({
'arr.0.name': 'item-1'
})
res = {
data:[{
arr:[{
name: 'item-1',
},{
name: 'item-2',
}]
}]
}
```
如果想查询arr内某个元素的name为item-1的记录(可以是数组内的任意一条name为item-1)可以使用如下写法
```js
const res = await db.collection('test').where({
'arr.name': 'item-1'
})
res = {
data:[{
arr:[{
name: 'item-1',
},{
name: 'item-2',
}]
}]
}
```
### 获取查询数量
......
......@@ -478,9 +478,9 @@ web控制台网址:[https://unicloud.dcloud.net.cn](https://unicloud.dcloud.ne
在web控制台可以对数据库进行编辑。在json文档中,输入字符串、数字、bool值都是常规的操作。但有2种特殊数据类型,时间和地理位置,在编辑时有特殊的写法,请注意:
#### 添加日期@editdb_date
#### 添加日期@editdb-date
在web控制台添加/修改数据时,如果输入"2020-12-02 12:12:12"会变成字符串,而不是日期格式。此时需通过以下方式添加日期类型数据。
在web控制台添加/修改数据时,如果输入`"2020-12-02 12:12:12"`会变成字符串,而不是日期格式。此时需通过以下方式添加日期类型数据。
<!-- {
"create_date": {
......@@ -496,7 +496,7 @@ web控制台网址:[https://unicloud.dcloud.net.cn](https://unicloud.dcloud.ne
}
```
#### 添加地理位置点@editdb_geopoint
#### 添加地理位置点@editdb-geopoint
```js
// 将location字段设置为经度116、纬度38的地理位置点
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册