Helper functions to leancloud sdk
Client
toObject (avObject)
const member = new AV.Member({
team: new AV.Team(),
nickname
})
toObject(member).id === member.id
toObject(member).createdAt === member.createdAt
toObject(member).updatedAt === member.updatedAt
toObject(member).team === member.team
toObject(member).nickname === member.nickname
cors(req, res, next)
import AV from 'leanengine'
import express from 'express'
const app = express()
app.use(cors)
app.use(AV.express())
proxy(protocol = 'https', host = 'api.leanengine.cn')
import AV from 'leanengine'
import express from 'express'
const app = express()
app.use(proxy())
app.use(AV.express())
class HookFunction
import AV from 'leanengine'
const hook = new HookFunction()
.connect(async ({ object: folder }) => {
const comments = await new AV.Query('File').equalTo('folder', folder).count()
if (comments.length > 0) throw 'Forbidden Delete. There are files in this folder'
})
.connect(async ({ object: folder }) => {
const handles = await new AV.Query('Handle').equalTo('folder', folder).count()
if (comments.length > 0) throw 'Forbidden Delete. There are handles open on this folder'
})
.connect(async ({ object: folder }) => {
const protection = await new AV.Query('Protection').equalTo('folder', folder).first()
if (protection) throw 'Forbidden Delete. This dir is under protection'
})
AV.Cloud.beforeDelete('Folder', hook.hook)