parse

import Parse from 'parse';
import { AsyncStorage } from 'react-native';

// 创建新的子类
var GameScore = Parse.Object.cextnd("GameScore")

// 创建该类的新实例
var gameScore = new GameScoere() 

// 位子类方法添加方法属性
var Monster = Parse.Object.extend("Monster", {
    hasSuperHumanStrength: function() {
        return this.get("strength") > 18;
    }
})
// 保存数据
gameScore.set("score", 1337);
gameScore.set('playerName', ' Sean Plott');
gameScore.set("cheatMode", false);

gameScore.save()
.then((gameScore) => {
    alert('new record')
}, err => {
    alert(err.message)
})

// 检索对象
var GameScoere = Parse.Object.extend("GameScore");
var query = new Parse.Query(GameScoere);
query.get("xWMyZ4YEGZ")
.then((gameScore) => {

}, err=> {

})

// 刷新云端数据,使用fetch
myObject.fetch().then((myObject)=>{

},err=>{

})

// 查询一个结果,使用first代替find
query.equalTo('playerEmail', "dast@example.com")
const object = await query.first()

// 跳过结果
query.skip(10)

// 对于数字和字符串可排序类型,可以控制返回结果顺序
query.ascending("score");
query.descending("score")

// 检索具有特定键值和没有特定键值的
query.exists("score");
query.doesNotExist("score");

// 匹配对象
const Team = Parse.Object.extend("Team");
const teamQuery = new Parse.Query(Team);
teamQuery.greaterThan("winPct", 0.5)
const userQuery = new Parse.Query(Parse.User);
userQuery.matchesKeyInQuery("hometown", "city", teamQuery);
const results = await userQuery.find()

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注