v0.0.4
This commit is contained in:
13
cloudfunctions/draftGet/index.js
Normal file
13
cloudfunctions/draftGet/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const cloud = require('wx-server-sdk')
|
||||
|
||||
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })
|
||||
const db = cloud.database()
|
||||
|
||||
exports.main = async () => {
|
||||
const { OPENID } = cloud.getWXContext()
|
||||
if (!OPENID) throw new Error('no openid in wx context')
|
||||
const res = await db.collection('drafts').where({ openid: OPENID }).limit(1).get()
|
||||
if (!res.data.length) return { draft: null }
|
||||
const record = res.data[0]
|
||||
return { draft: record.draft || null, updatedAt: record.updatedAt }
|
||||
}
|
||||
8
cloudfunctions/draftGet/package.json
Normal file
8
cloudfunctions/draftGet/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "draftGet",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user