本文整理汇总了TypeScript中leancloud-storage.Object.save方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Object.save方法的具体用法?TypeScript Object.save怎么用?TypeScript Object.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leancloud-storage.Object
的用法示例。
在下文中一共展示了Object.save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
}
});
示例2: 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 => {
});
});
示例3: 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();
});
});
示例4: 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=>{
});
});
示例5: 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) => {
}
);
});