Leancloud Cloud Code如何插入数据到数据库

我在看leancloud的cloud code文档,里面提到可以自定义函数。我现在有个需求,就是想建一个定时任务,定时get一些数据并插入数据库。但是leancloud没有提到怎么使用cloud code插入数据到数据库。请问有类似的教程或指南吗?我翻遍文档都没找到。

阅读 4.9k
1 个回答

云代码使用 JavascriptSDK 操作即可。

文档如下:
https://leancloud.cn/docs/js_guide.html#保存对象

var gameScore = new GameScore();
gameScore.set("score", 1337);
gameScore.set("playerName", "Sean Plott");
gameScore.set("cheatMode", false);
gameScore.save(null, {
  success: function(gameScore) {
    // Execute any logic that should take place after the object is saved.
    alert('New object created with objectId: ' + gameScore.id);
  },
  error: function(gameScore, error) {
    // Execute any logic that should take place if the save fails.
    // error is a AV.Error with an error code and description.
    alert('Failed to create new object, with error code: ' + error.message);
  }
});
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题