Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Young_sapling
unidocs-zh
提交
642f2e4b
U
unidocs-zh
项目概览
Young_sapling
/
unidocs-zh
与 Fork 源项目一致
Fork自
DCloud / unidocs-zh
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
unidocs-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
642f2e4b
编写于
4月 03, 2023
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs: update uniCloud jql -ext
上级
739189bc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
16 deletion
+12
-16
docs/uniCloud/jql-schema-ext.md
docs/uniCloud/jql-schema-ext.md
+12
-16
未找到文件。
docs/uniCloud/jql-schema-ext.md
浏览文件 @
642f2e4b
...
...
@@ -94,7 +94,7 @@ ext.js里引入公共模块的机制:
|limit |number |- |否 |返回的结果集(文档数量)的限制,新增于
`3.7.0`
|
|sample |object |- |否 |sample(随机选取)方法的参数,新增于
`3.7.0`
|
|docId |string |- |否 |doc方法的参数,数据库记录的_id,新增于
`3.7.0`
|
|isGetTempLookup |boolean |- |联表触发时必备
,仅主表触发器有此参数
|联表查询时用于标识,本次查询是否使用了getTemp,新增于
`3.7.1`
|
|isGetTempLookup |boolean |- |联表触发时必备
|联表查询时用于标识,本次查询是否使用了getTemp,新增于
`3.7.1`
|
#### secondaryCollection@secondary-collection
...
...
@@ -475,12 +475,11 @@ module.exports {
beforeUpdate
:
async
function
({
collection
,
operation
,
where
,
docId
,
updateData
,
clientInfo
}
=
{})
{
const
id
=
where
&&
where
.
_id
if
(
typeof
id
===
'
string
'
&&
(
updateData
.
title
||
updateData
.
content
))
{
//如果字段较多,也可以不列举字段,删掉后半个判断
if
(
typeof
docId
===
'
string
'
&&
(
updateData
.
title
||
updateData
.
content
))
{
//如果字段较多,也可以不列举字段,删掉后半个判断
if
(
updateData
.
content
)
{
// updateData.summary = 'xxxx' // 根据content生成summary
}
...
...
@@ -500,16 +499,15 @@ module.exports {
afterRead
:
async
function
({
collection
,
operation
,
where
,
docId
,
field
,
clientInfo
}
=
{})
{
const
db
=
uniCloud
.
database
()
const
id
=
where
&&
where
.
_id
// clientInfo.uniIdToken可以解出客户端用户信息,再进行判断是否应该加1。为了让示例简单清晰,此处省略相关逻辑
if
(
typeof
i
d
===
'
string
'
&&
field
.
includes
(
'
content
'
))
{
if
(
typeof
docI
d
===
'
string
'
&&
field
.
includes
(
'
content
'
))
{
// 读取了content字段后view_count加1
await
db
.
collection
(
'
article
'
).
where
(
where
).
update
({
await
db
.
collection
(
'
article
'
).
doc
(
docId
).
update
({
view_count
:
db
.
command
.
inc
(
1
)
})
}
...
...
@@ -527,15 +525,14 @@ module.exports {
beforeDelete
:
async
function
({
collection
,
operation
,
where
,
docId
,
clientInfo
}
=
{})
{
const
db
=
uniCloud
.
database
()
const
id
=
where
&&
where
.
_id
if
(
typeof
id
!==
'
string
'
)
{
// 此处也可以加入管理员可以批量删除的逻辑
if
(
typeof
docId
!==
'
string
'
)
{
// 此处也可以加入管理员可以批量删除的逻辑
throw
new
Error
(
'
禁止批量删除
'
)
}
const
res
=
await
db
.
collection
(
'
article
'
).
where
(
where
).
get
()
const
res
=
await
db
.
collection
(
'
article
'
).
doc
(
docId
).
get
()
const
record
=
res
.
data
[
0
]
if
(
record
)
{
await
db
.
collection
(
'
article-archived
'
).
add
(
record
)
...
...
@@ -632,12 +629,11 @@ uniCloud.databaseForJQL({
module
.
exports
=
{
trigger
:
{
afterRead
:
async
function
({
where
,
docId
,
field
,
clientInfo
}
=
{})
{
const
id
=
where
&&
where
.
_id
if
(
typeof
id
!==
'
string
'
||
!
field
.
includes
(
'
content
'
))
{
if
(
typeof
docId
!==
'
string
'
||
!
field
.
includes
(
'
content
'
))
{
return
}
const
dbJQL
=
uniCloud
.
databaseForJQL
({
...
...
@@ -646,7 +642,7 @@ module.exports = {
})
await
dbJQL
.
collection
(
'
article-view-log
'
)
.
add
({
article_id
:
i
d
,
article_id
:
docI
d
,
reader_id
:
dbJQL
.
getCloudEnv
(
'
$cloudEnv_uid
'
)
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录