-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 对称签名等修复 * Laf对称加密支持一下 * 1 * 测试数据切换 * 1 * v1.11.0 * 更新云函数
- Loading branch information
Showing
11 changed files
with
177 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: __interceptor__ | ||
methods: | ||
- GET | ||
- POST | ||
- GET | ||
tags: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// addRecords 数据库操作云函数 | ||
import cloud from '@lafjs/cloud' | ||
import { EJSON } from 'bson' | ||
|
||
const db = cloud.database(); | ||
const _ = db.command; | ||
|
||
exports.main = async function (ctx: FunctionContext) { | ||
// body, query 为请求参数, auth 是授权对象 | ||
const { auth, body, query } = ctx; | ||
|
||
const collection = body.collection; | ||
var data = body.data; | ||
data = Buffer.from(data, "base64").toString('utf-8'); | ||
data = JSON.parse(data); | ||
console.log("curdOp param:", body); | ||
|
||
for (var idx in data) { | ||
var record = EJSON.parse(data[idx]); | ||
console.log("mdate type:", typeof (record.mdate)); | ||
var id = record._id; | ||
console.log(id); | ||
delete record._id; | ||
await db.collection(collection).doc(id).set(record); | ||
} | ||
return "success"; | ||
} | ||
|
||
async function deleteAll(collection) { | ||
return await db.collection(collection).remove({ multi: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: addRecords | ||
methods: | ||
- POST | ||
tags: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import cloud from '@lafjs/cloud' | ||
|
||
const colls = [] | ||
|
||
export default async function (ctx: FunctionContext) { | ||
//查询全部集合名 | ||
const allColls = await cloud.mongo.db.listCollections().toArray(); | ||
let names = []; | ||
for (const x of allColls) { | ||
if (x.name.startsWith("__")) { | ||
continue; | ||
} | ||
names.push(x.name); | ||
} | ||
console.log(names); | ||
|
||
// 删除coll | ||
const db = cloud.database(); | ||
for (const coll of colls) { | ||
const count = (await db.collection(coll).count()).total; | ||
console.log(`dropping ${coll} with ${count} items...`); | ||
cloud.mongo.db.dropCollection(coll); | ||
console.log(`dropping ${coll} done.`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: dropdb | ||
methods: [] | ||
tags: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- collectionName: photo | ||
rules: | ||
read: true | ||
count: true | ||
update: false | ||
remove: false | ||
add: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,77 @@ | ||
- collectionName: setting | ||
- collectionName: cat | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: false | ||
- collectionName: science | ||
- collectionName: comment | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: false | ||
- collectionName: comment | ||
add: openid | ||
- collectionName: feedback | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: true | ||
- collectionName: news | ||
add: openid | ||
- collectionName: inter | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: false | ||
- collectionName: reward | ||
add: openid | ||
- collectionName: news | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: false | ||
- collectionName: user | ||
- collectionName: photo | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: false | ||
add: openid | ||
- collectionName: photo_rank | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: false | ||
- collectionName: inter | ||
- collectionName: reward | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: true | ||
- collectionName: cat | ||
add: false | ||
- collectionName: science | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: false | ||
- collectionName: photo | ||
- collectionName: setting | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: true | ||
- collectionName: feedback | ||
add: false | ||
- collectionName: user | ||
rules: | ||
read: true | ||
count: true | ||
read: openid | ||
count: openid | ||
update: false | ||
remove: false | ||
add: true | ||
add: false |