13518219792

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

Clouda API使用手册之Router Model Collection

Router

用于建立URL(其路径部分)和Controller的对应关系,一个Controller可以对应多个URL,但是一个URL只能对应一个Controller。

创新互联公司专业为企业提供安岳网站建设、安岳做网站、安岳网站设计、安岳网站制作等企业网站建设、网页设计与制作、安岳企业网站模板建站服务,10余年安岳做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

#p#

Model

Model用来定义App的数据模型。

 
 
  1. Model.student = function(exports){ 
  2.     exports.config = { 
  3.         fields: [ 
  4.             {name : 'studentName', type: 'string'}, 
  5.             {name : 'age',         type: 'int'}, 
  6.             {name : 'gender',      type: 'string'} 
  7.         ] 
  8.     }; 
  9.  }; 
属性
类型意义
int整形
datetime日期
string字符串数
object对象
array数组
model数据模型
collection数据集合
方法意义
length[min,max]字段值的长度在min-max的范围。
minlength(min)字段值不小于min
maxlength(min)字段值不大于min
required字段值不能为空
unique字段值必须唯一
telephone字段值必须为电话号码格式
mobilephone字段值必须为手机号码格式,长度为11位且必须为数字
email字段值必须为email格式
onlyletter字段值必须是字母
nospecialchars字段值不能包含特殊字符
date字段值必须是日期格式
url字段值必须是URL
chinese字段值必须是中文

注:多个验证条件之间使用" | "连接

 {name: 'name', type: 'string', validation:'length[1,20]|required'},

#p#

Collection

Collection是Model的集合,我们之前曾使用过的subscribe()返回的结果集即是Collection。

 
 
  1. session.studentCollection = env.subscribe("pub-allStudents",function(myCollection){ 
  2.  
  3. }); 

网站题目:Clouda API使用手册之Router Model Collection
本文来源:http://cdbrznjsb.com/article/ccedipc.html

其他资讯

让你的专属顾问为你服务