提交
This commit is contained in:
32
甲情_甲意/cloud/functions/query/index.js
Normal file
32
甲情_甲意/cloud/functions/query/index.js
Normal file
@ -0,0 +1,32 @@
|
||||
const cloud = require('@alipay/faas-server-sdk');
|
||||
|
||||
exports.main = async (event, context) => {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
// 获取 cloud 环境中的 mongoDB 数据库对象
|
||||
|
||||
const db = cloud.database();
|
||||
|
||||
|
||||
|
||||
// 使用 where 条件查询集合对象test
|
||||
|
||||
const data = await db.collection('user')
|
||||
|
||||
|
||||
// 使用 get 获取文档数据
|
||||
|
||||
.get();
|
||||
|
||||
return { success: true, msg: '查询成功', data };
|
||||
|
||||
} catch (err) {
|
||||
|
||||
return { success: false, msg: `查询失败 - ${err.toString()}` };
|
||||
|
||||
}
|
||||
|
||||
};
|
Reference in New Issue
Block a user