1,新增单词测试模块
This commit is contained in:
40
uniCloud-aliyun/cloudfunctions/createQuestionItem/index.js
Normal file
40
uniCloud-aliyun/cloudfunctions/createQuestionItem/index.js
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
const db = uniCloud.database();
|
||||
exports.main = async (event, context) => {
|
||||
// 创建数据库
|
||||
const collection = db.collection('questionList');
|
||||
// 添加示例数据
|
||||
const res = await collection.add({
|
||||
"wordData": {
|
||||
"level": 1,
|
||||
"wordName": "apple",
|
||||
"phonetic": "abdc",
|
||||
"pronunciation": "url:xx",
|
||||
"options": [
|
||||
{
|
||||
"itemId": "A",
|
||||
"itemContent": "苹果",
|
||||
"right": true
|
||||
},
|
||||
{
|
||||
"itemId": "B",
|
||||
"itemContent": "香蕉"
|
||||
},
|
||||
{
|
||||
"itemId": "C",
|
||||
"itemContent": "橙子"
|
||||
},
|
||||
{
|
||||
"itemId": "D",
|
||||
"itemContent": "柠檬"
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
//event为客户端上传的参数
|
||||
event = '测试数据'
|
||||
console.log('后端接口测试数据 : ', event)
|
||||
|
||||
//返回数据给客户端
|
||||
return event
|
||||
};
|
||||
22
uniCloud-aliyun/cloudfunctions/provideQuestion/index.js
Normal file
22
uniCloud-aliyun/cloudfunctions/provideQuestion/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
const db = uniCloud.database();
|
||||
exports.main = async (event, context) => {
|
||||
//event为客户端上传的参数
|
||||
// const count = await db.collection('questionList').count()
|
||||
// 根据level字段返回不同的数据
|
||||
let res = await db.collection('questionList').where({
|
||||
wordData:{
|
||||
level:event.level
|
||||
}
|
||||
}).limit(1).get()
|
||||
let data = res.data
|
||||
console.log('入参:页码+难度', event,res)
|
||||
|
||||
// let res
|
||||
//返回数据给客户端
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'success',
|
||||
data
|
||||
}
|
||||
};
|
||||
@@ -1,12 +1,12 @@
|
||||
// 本文件用于,使用JQL语法操作项目关联的uniCloud空间的数据库,方便开发调试和远程数据库管理
|
||||
// 编写clientDB的js API(也支持常规js语法,比如var),可以对云数据库进行增删改查操作。不支持uniCloud-db组件写法
|
||||
// 可以全部运行,也可以选中部分代码运行。点击工具栏上的运行按钮或者按下【F5】键运行代码
|
||||
// 如果文档中存在多条JQL语句,只有最后一条语句生效
|
||||
// 如果混写了普通js,最后一条语句需是数据库操作语句
|
||||
// 此处代码运行不受DB Schema的权限控制,移植代码到实际业务中注意在schema中配好permission
|
||||
// 不支持clientDB的action
|
||||
// 数据库查询有最大返回条数限制,详见:https://uniapp.dcloud.net.cn/uniCloud/cf-database?id=limit
|
||||
// 详细JQL语法,请参考 https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=jsquery
|
||||
|
||||
// 下面示例查询uni-id-users表的所有数据
|
||||
db.collection('uni-id-users').get();
|
||||
// 本文件用于,使用JQL语法操作项目关联的uniCloud空间的数据库,方便开发调试和远程数据库管理
|
||||
// 编写clientDB的js API(也支持常规js语法,比如var),可以对云数据库进行增删改查操作。不支持uniCloud-db组件写法
|
||||
// 可以全部运行,也可以选中部分代码运行。点击工具栏上的运行按钮或者按下【F5】键运行代码
|
||||
// 如果文档中存在多条JQL语句,只有最后一条语句生效
|
||||
// 如果混写了普通js,最后一条语句需是数据库操作语句
|
||||
// 此处代码运行不受DB Schema的权限控制,移植代码到实际业务中注意在schema中配好permission
|
||||
// 不支持clientDB的action
|
||||
// 数据库查询有最大返回条数限制,详见:https://uniapp.dcloud.net.cn/uniCloud/cf-database?id=limit
|
||||
// 详细JQL语法,请参考 https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=jsquery
|
||||
|
||||
// 下面示例查询uni-id-users表的所有数据
|
||||
db.collection('uni-id-users').get();
|
||||
|
||||
Reference in New Issue
Block a user