本文整理匯總了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) => {
}
);
});