How to use the leanengine.Object function in leanengine

To help you get started, we’ve selected a few leanengine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leancloud / leanengine-nodejs-demos / functions / captcha-storage.js View on Github external
AV.Cloud.define('getCaptchaImageStorage', async request => {
  const captchaCode = parseInt(Math.random() * 9000 + 1000)
  const picture = new Captchapng(80, 30, captchaCode)

  picture.color(0, 0, 0, 0)
  picture.color(80, 80, 80, 255)

  // 使用一个空的 ACL,确保没有任何用户可读可写 captcha 对象
  // 后续所有对 captcha 对象的查询和修改操作都在云引擎中,
  // 并且使用 masterKey 权限进行操作。
  const captcha = await new AV.Object('Captcha').setACL(new AV.ACL()).save({
    code: captchaCode,
    isUsed: false,
  })

  return {
    captchaId: captcha.id,
    imageUrl: 'data:image/png;base64,' + picture.getBase64()
  }
})