Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
033bfb35
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
033bfb35
编写于
12月 31, 2020
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: uniCloud
上级
4e8aaa0b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
3 deletion
+61
-3
docs/uniCloud/cf-database.md
docs/uniCloud/cf-database.md
+58
-0
docs/uniCloud/quickstart.md
docs/uniCloud/quickstart.md
+3
-3
未找到文件。
docs/uniCloud/cf-database.md
浏览文件 @
033bfb35
...
...
@@ -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
'
,
}]
}]
}
```
### 获取查询数量
...
...
docs/uniCloud/quickstart.md
浏览文件 @
033bfb35
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录