apiCloud中的数据库操作mcm模块中的model对象

简介:

1.添加

        var model = api.require('model');
        model.config({
            appId:'xxx',
            appKey: 'xxx',
            host: 'https://d.apicloud.com'
        });
        model.insert({
            class: 'user',
            value: {
                username : 'test',
                password : '123456'
            }
        }, function(ret, err){
            if( ret ){
                alert( JSON.stringify( ret ) );
            }else{
                alert( JSON.stringify( err ) );
            }
        });
AI 代码解读

2.修改

        var model = api.require('model');
        model.config({
            appId:'xxx',
            appKey: 'xxx',
            host: 'https://d.apicloud.com'
        });


        model.updateById({
            class: 'user',
            id: '57eb807babca25f4649f1c0f',
            value: {
                username: 'Tom'
            }
        }, function(ret, err){
            if( ret ){
                alert( JSON.stringify( ret ) );
            }else{
                alert( JSON.stringify( err ) );
            }
        });
AI 代码解读

3.删除

        var model = api.require('model');
        model.config({
            appId:'xxx',
            appKey: 'xxx',
            host: 'https://d.apicloud.com'
        });
        
        model.deleteById({
            class: 'user',
            id: '57eb807babca25f4649f1c0f'
        }, function(ret, err){
            if( ret ){
                alert( JSON.stringify( ret ) );
            }else{
                alert( JSON.stringify( err ) );
            }
        });
AI 代码解读

4.查找

        var model = api.require('model');
        model.config({
            appId:'xxx',
            appKey: 'xxx',
            host: 'https://d.apicloud.com'
        });

        model.findById({
            class: 'user',
            id: '57eb82c5abca25f4649f1d22'
        }, function(ret, err){
            if( ret ){
                alert( JSON.stringify( ret ) );
            }else{
                alert( JSON.stringify( err ) );
            }
        });
AI 代码解读

5.查找全部

        var model = api.require('model');
        model.config({
            appId:'xxx',
            appKey: 'xxx',
            host: 'https://d.apicloud.com'
        });

        model.findAll({
            class: "user",
            qid: ''
        }, function( ret, err ) {
            if( ret ){
                alert( JSON.stringify( ret ) );
            }else{
                alert( JSON.stringify( err ) );
            }
        });
AI 代码解读

6.查询是否存在

        var model = api.require('model');
        model.config({
            appId:'xxx',
            appKey: 'xxx',
            host: 'https://d.apicloud.com'
        });
        
        model.exist({
            class: "user",
            id: "57eb82c5abca25f4649f1d22"
        }, function( ret, err ) {
            if( ret ){
                alert( JSON.stringify( ret ) );
            }else{
                alert( JSON.stringify( err ) );
            }
        });
AI 代码解读

7.结合query进行查询

        var model = api.require('model');
        model.config({
            appId:'xxx',
            appKey: 'xxx',
            host: 'https://d.apicloud.com'
        });

        var query = api.require('query');
        var queryId = query.createQuery();
        query.whereNotEqual({  // 查询id不等于57eb82c5abca25f4649f1d22的数据
            qid: queryId,
            column: 'id',
            value: '57eb82c5abca25f4649f1d22'
        });
        
        model.findAll({
            class: "user",
            qid: queryId
        }, function( ret, err ) {
            if( ret ){
                alert( JSON.stringify( ret ) );
            }else{
                alert( JSON.stringify( err ) );
            }
        });



本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/5917049.html,如需转载请自行联系原作者
AI 代码解读
目录
打赏
0
0
0
0
64
分享
相关文章
【赵渝强老师】达梦数据库的数据库对象
达梦数据库包含基本与复杂两大类数据库对象。基本对象如表、索引、视图、序列和同义词,通过单一DDL语句创建和管理。表是数据存储核心,支持多种数据类型;索引提升查询速度,常见类型包括聚集、唯一、函数等索引;视图提供虚表功能;序列生成有序整数;同义词简化对象访问。复杂对象包括存储过程、函数和触发器,需用DMSQL语言开发,适用于更复杂的业务逻辑处理。文中通过实例详细介绍了各类对象的创建与使用方法。
142 3
|
6月前
|
陪玩平台中支付与结算模块的代码,陪玩系统数据库设计与代码实现
第三方支付平台对接涉及与微信支付、支付宝等API接口的调用,确保用户支付流程顺畅。结算模块根据业务规则计算陪玩师收益,强调安全性、异常处理、可扩展性和日志记录。数据库设计涵盖用户、陪玩者、订单等信息的存储管理,确保系统稳定运行。
173 12
canal-starter 监听解析 storeValue 不一样,同样的sql 一个在mybatis执行 一个在数据库操作,导致解析不出正确对象
canal-starter 监听解析 storeValue 不一样,同样的sql 一个在mybatis执行 一个在数据库操作,导致解析不出正确对象
Django学习二:配置mysql,创建model实例,自动创建数据库表,对mysql数据库表已经创建好的进行直接操作和实验。
这篇文章是关于如何使用Django框架配置MySQL数据库,创建模型实例,并自动或手动创建数据库表,以及对这些表进行操作的详细教程。
299 0
Django学习二:配置mysql,创建model实例,自动创建数据库表,对mysql数据库表已经创建好的进行直接操作和实验。
php连接数据库之PDO,PDO的简单使用和预定义占位符的使用以及PDOStatement对象的使用,占位符的不同形式,bindValue和bindParam绑定预定义占位符参数的区别
本文介绍了PHP中PDO(PHP Data Objects)扩展的基本概念和使用方法。内容包括PDO类和PDOStatement类的介绍,PDO的简单使用,预定义占位符的使用方法,以及PDOStatement对象的使用。文章还讨论了绑定预定义占位符参数的不同形式,即bindValue和bindParam的区别。通过具体示例,展示了如何使用PDO进行数据库连接、数据查询、数据插入等操作。
php连接数据库之PDO,PDO的简单使用和预定义占位符的使用以及PDOStatement对象的使用,占位符的不同形式,bindValue和bindParam绑定预定义占位符参数的区别
学成在线笔记+踩坑(3)——【内容模块】课程分类查询、课程增改删、课程计划增删改查,统一异常处理+JSR303校验
课程分类查询、课程新增、统一异常处理、统一封装结果类、JSR303校验、修改课程、查询课程计划、新增/修改课程计划
学成在线笔记+踩坑(3)——【内容模块】课程分类查询、课程增改删、课程计划增删改查,统一异常处理+JSR303校验
手把手教你管理PostgreSQL数据库及其对象
手把手教你管理PostgreSQL数据库及其对象
383 0
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误
127 0

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问