欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

ApiCloud链接云端数据库

发布时间:2023/12/20 数据库 51 豆豆
生活随笔 收集整理的这篇文章主要介绍了 ApiCloud链接云端数据库 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

apicloud的mcm模块其实就是应用云端数据库完成一系列操作,说到云端数据,当然要先创建数据库,按照如下方式创建,当然,双击就可添加数据



之后就简单了,在项目的页面里写上这样的查询就ok了,其中appid,appkey都是来自appcloud官网数据

  • function test2() {
  • var userId = 'userId';
  • var friendUserId = 'friendUserId';
  • var model = api.require('model');
  • var query = api.require('query');
  • model.config({
  • appId : 'A6903547912689',
  • appKey : '8C6CB9D1-FD18-6B0A-859C-EA0D1A2F3927',
  • host : 'https://d.apicloud.com'
  • });
  • query.createQuery(function(ret, err) {
  • if (ret && ret.qid) {
  • //console.log(ret.qid);
  • query.whereEqual({
  • qid : ret.qid,
  • column : 'userId',
  • value : userId
  • });
  • query.whereEqual({
  • qid : ret.qid,
  • column : 'friendUserId',
  • value : friendUserId
  • });
  • model.findAll({
  • class : 'friend',
  • qid : ret.qid
  • }, function(ret, err) {
  • //coding...
  • console.log("ret=" + JSON.stringify(ret));
  • console.log("err=" + JSON.stringify(err));
  • });
  • }
  • });
  • }

  • mcm模块包含了model、user、relation和query等对象

    完成!

    apiready = function () { var model = api.require( 'model' ); var query = api.require( 'query' ); model.config({ appid : 'A6911833617674' , appKey : '08DDA53D-8553-76B0-DA8D-3991430F1512' , host : 'https://d.apicloud.com' }); query.createQuery({ }, function(ret, err) { //coding... if (ret && ret.qid) { model.findAll({ class : 'ware' , qid : ret.qid }, function(ret, err) { //coding... var abcd = $api.byId( 'sectionmy' ); //获取到需要填充的div for ( var i = 0 ; i < ret.length; i++) { $api.append(abcd, "<div>" +ret[i].description+ "</div>" ); } }); } }); }

    总结

    以上是生活随笔为你收集整理的ApiCloud链接云端数据库的全部内容,希望文章能够帮你解决所遇到的问题。

    如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。