-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud.js
More file actions
34 lines (27 loc) · 819 Bytes
/
cloud.js
File metadata and controls
34 lines (27 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var AV = require('leanengine');
var _ = require('underscore');
var records = require('./api/records');
/**
* 一个简单的云代码方法
*/
AV.Cloud.define('hello', function(req, res) {
console.log(req)
res.success('Hello world!');
});
AV.Cloud.define("getAllMyRecords", records.getAllMyRecords);
AV.Cloud.define("report1Record", records.report1Record);
// 从 content 中查找 tag 的正则表达式
var tagRe = /#(\w+)/g
/**
* Todo 的 beforeSave hook 方法
* 将 content 中的 #<tag> 标记都提取出来,保存到 tags 属性中
*/
/*AV.Cloud.beforeSave('Todo', function(req, res) {
var todo = req.object;
var content = todo.get('content');
var tags = todo.get('content').match(tagRe);
tags = _.uniq(tags);
todo.set('tags', tags);
res.success();
})*/
module.exports = AV.Cloud;