本文整理汇总了TypeScript中leancloud-storage.Object.set方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Object.set方法的具体用法?TypeScript Object.set怎么用?TypeScript Object.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leancloud-storage.Object
的用法示例。
在下文中一共展示了Object.set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('AVObject#save', function (done) {
let todoFolder: AV.Object = new AV.Object('TodoFolder');// 新建对象
todoFolder.set('name', '工作');// 设置名称
todoFolder.set('priority', 1);// 设置优先级
todoFolder.save<AV.Object>().then(
(data) => {
let savedTodoFolder: AV.Object = data;
chai.assert.isNotNull(savedTodoFolder, "new an AVObject with extend");
done();
}, (error) => {
if (error) throw error;
done();
});
});
示例2: before
before(function () {
// runs before all tests in this block
/*
AV.init({
appId:'{put-test-appId-here}}',
appKey:'{put-test-appKey-here}'});
*/
let todo: AV.Object = new AV.Object('Todo');// 新建对象
todo.set('title', '工程师周会');// 设置地点
todo.set('priority', 1);// 设置优先级
todo.set('location', '二楼会议室');// 设置地点
return todo.save<AV.Object>().then(todo=>{
testObjectId = todo.id;
},error=>{
});
});
示例3: test
test('test', (t) => {
t.plan(1);
let todo = new AV.Object('Todo');
todo.set('title', '工程师周会');
todo.set('content', '每周工程师会议,周一下午2点');
todo.save<AV.Object>().then(
(data) => {
// data 是根据 todo.save<AV.Object> 传入的泛型参数决定
let savedTodo : AV.Object = data;
t.assert(savedTodo.id !== null, 'save todo object');
},
(error) => {
}
);
});
示例4: before
before(function () {
// runs before all tests in this block
let todo: AV.Object = new AV.Object('Todo');// 新建对象
todo.set('location', '二楼大会议室');
return todo.save<AV.Object>().then(todo => {
todoObjectId = todo.id;
}, error => {
});
});
示例5: it
it('#AVObject#dataType', function (done) {
try {
let testNumber: number = 13;
let testString: string = 'here is a test string';
let testDate: Date = new Date('2016-06-04');
let testNumberArray: Array<number> = [1, 2, 3];
let testStringArray: Array<string> = ['here', 'is', 'a', 'string', 'array'];
let testObjectType: Object = { name: 'LeanCloud', url: 'https://leancloud.cn' };
let testAVObject = new AV.Object('TestClass');
testAVObject.set('testNumber', testNumber);
testAVObject.set('testString', testString);
testAVObject.set('testDate', testDate);
testAVObject.set('testNumberArray', testNumberArray);
testAVObject.set('testStringArray', testStringArray);
testAVObject.set('testObject', testObjectType);
testAVObject.save<AV.Object>().then(
(data) => {
chai.assert.isNotNull(data.id);
done();
}, (error) => {
if (error) throw error;
done();
});
}
catch (e) {
chai.assert.isNull(e);
}
});
示例6: it
it('AVObject#setACL', function (done) {
try {
// 示例代码-Start
// 新建一个帖子对象
let post = new AV.Object('Post');
post.set("title", "大家好,我是新人");
// 新建一个角色,并把为当前用户赋予该角色
administratorRole = new AV.Role(randomRolename);//新建角色
let relation = administratorRole.getUsers();
administratorRole.getUsers().add(AV.User.current());//为当前用户赋予该角色
administratorRole.save<AV.Role>().then(administratorRole => {//角色保存成功
// 新建一个 ACL 实例
let objectACL = new AV.ACL();
objectACL.setPublicReadAccess(true);
objectACL.setRoleWriteAccess(administratorRole, true);
// 将 ACL 实例赋予 Post 对象
post.setACL(objectACL);
post.save<AV.Object>().then(post => {
chai.assert.isNotNull(post.id);
done();
}, error => {
if (error) throw error;
});
}, error => {
//角色保存失败,处理 error
});
// 示例代码-End
}
catch (e) {
chai.assert.isNull(e);
}
});