我想用javascript更新我在parse.com中已有的对象; 我做的是我首先用查询退回对象,但我不知道如何更新它.
这是我使用的代码,它有什么不对吗?
var GameScore = Parse.Object.extend("Driver");
var query = new Parse.Query(GameScore);
query.equalTo("DriverID", "9");
query.find({
success: function(results) {
alert("Successfully retrieved " + results.length + "DName");
results.set("DName", "aaaa");
results.save();
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
Run Code Online (Sandbox Code Playgroud) 我正在使用Parse作为我的后端.我在设置对象之间的正确关系时遇到问题.
我基本上有一个名为Post的类,每个帖子属于一个用户(PFUser),并且在获取帖子时我希望用帖子提取用户信息.
@interface Post : PFObject<PFSubclassing>
@property (nonatomic, strong) NSDate *time;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *body;
@property (nonatomic, strong, readonly) PFRelation *user;
// User in backed is defined as a relationship to _user
@end
// Saving the post
[post.user addObject:[PFUser currentUser];
[post saveInBackground];
Run Code Online (Sandbox Code Playgroud)
这工作正常,并将帖子与该用户相关联,但是当我稍后尝试获取帖子时,似乎我无法从PFRelation获取_user的实例.
处理这个问题的正确方法是什么?尝试将PFRelation更改为PFUser,但这会因为尝试在PFUser对象上调用save而崩溃
我的问题很简单,但我的代码不起作用.我想将ParseQuery的结果排序到ParseQueryAdapter中,然后再将其显示到ListView中.
products.addOnQueryLoadListener(new ParseQueryAdapter.OnQueryLoadListener<Product>() {
@Override
public void onLoaded(List<Product> data, Exception e) {
Collections.sort(data, LastDealComparator);
products.notifyDataSetInvalidated();
}
@Override
public void onLoading() {
}
});
Run Code Online (Sandbox Code Playgroud)
我检查调试器数据是按比较器排序的......但是没有更新到ParseQueryAdapter ... notifyDataSetInvalidated什么都不做.
有关信息,最初我的问题是对指针字段排序查询:
query.orderByDescending("deal.date");
Run Code Online (Sandbox Code Playgroud)
但那也不行......所以我写了一个手动排序.
我在我的项目中使用Parse SDK进行推送通知.我已经didFinishLaunchingWithOptions:在parse.com上添加了代码
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
Run Code Online (Sandbox Code Playgroud)
它的工作正常,如果设备或模拟器版本是iOS 8,但它在iOS 6.1中不起作用,并显示消息
[UIApplication registerUserNotificationSettings:]: unrecognized selector sent to instance 0x208406c0
谁能告诉我怎么解决呢?
我目前正在使用1.6.1通过CocoaPods(=最新)
在我的swift项目中,我启用了localdatastore,然后设置了解析应用程序ID.之后,我加载一个故事板,它是一个PFQueryTableViewController子类.真的没什么特别的.但它仍然崩溃.它似乎在Parse内部崩溃[PFQuery setCachePolicy:]
可能有什么不对?如何使离线功能正常工作?
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Method not allowed when Pinning is enabled.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001078a0f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000107ea3bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001078a0e6d +[NSException raise:format:] + 205
3 NMC-Goes 0x00000001044abe44 -[PFQuery setCachePolicy:] + 35
4 NMC-Goes 0x00000001043f6e85 -[PFQueryTableViewController queryForTable] + 341
5 NMC-Goes 0x00000001043f712e -[PFQueryTableViewController loadObjects:clear:] + 110
6 NMC-Goes 0x00000001043f70ba -[PFQueryTableViewController loadObjects] + 58
7 NMC-Goes 0x00000001043f69f9 -[PFQueryTableViewController viewDidLoad] + 73 …Run Code Online (Sandbox Code Playgroud) 这是我第一次使用parse.com php SDK,我尝试执行以下代码
<?php require '../autoload.php';
use Parse\ParseObject;
use Parse\ParseClient;
ParseClient::initialize( "Zsr...", "BzM..", "D..." );
$gameScore = new ParseObject("GameScore");
$gameScore->set("score", 1337);
$gameScore->set("playerName", "Sean Plott");
$gameScore->set("cheatMode", false);
try {
$gameScore->save();
echo 'New object created with objectId: ' . $gameScore->getObjectId();
} catch (ParseException $ex) {
// Execute any logic that should take place if the save fails.
// error is a ParseException object with an error code and message.
echo 'Failed to create new object, with error message: ' + $ex->getMessage();
} …Run Code Online (Sandbox Code Playgroud) 我在这方面遇到过类似的问题,但找不到答案.我需要使用Facebook SDKwith Parse.我使用的是最新的Parse SDK和最新的Facebook SDK.我已经按照Parse.com上的说明非常密切地使用Facebook与Parse,这意味着我已经将Parse AND Bolts框架拖入我的项目中.
当我构建我的项目时,我收到一个链接错误:
对于架构x86_64的未定义的符号: "_FBTokenInformationExpirationDateKey",从参考: - [PFFacebookTokenCachingStrategy cacheTokenInformation:]在ParseFacebookUtils(PFFacebookTokenCachingStrategy.o) - 在ParseFacebookUtils [PFFacebookTokenCachingStrategy EXPIRATIONDATE](PFFacebookTokenCachingStrategy.o) - [PFFacebookTokenCachingStrategy setExpirationDate:]在ParseFacebookUtils(PFFacebookTokenCachingStrategy.o ) "_FBTokenInformationTokenKey",从参考: - [PFFacebookTokenCachingStrategy的accessToken]在ParseFacebookUtils(PFFacebookTokenCachingStrategy.o) - [PFFacebookTokenCachingStrategy setAccessToken:]在ParseFacebookUtils(PFFacebookTokenCachingStrategy.o) "_FBTokenInformationUserFBIDKey",从参考: - [PFFacebookTokenCachingStrategy facebookId]在ParseFacebookUtils(PFFacebookTokenCachingStrategy. o) - ParseFacebookUtils(PFFacebookTokenCachingStrategy.o)中的[PFFacebookTokenCachingStrategy setFacebookId:]"_ OBJC_CLASS _ $ _ FBAppCall",引自:objc-class-ref i n ParseFacebookUtils(PFFacebookAuthenticationProvider.o)"_ OBJC_CLASS _ $ _ FBRequest",引自:ParseFacebookUtils中的objc-class-ref(PFFacebookAuthenticationProvider.o)"_ OBJC_CLASS _ $ _ FBSession",引自:ParseFacebookUtils中的objc-class-ref(PFFacebookAuthenticationProvider.o)" _OBJC_CLASS _ $ _ FBSessionTokenCachingStrategy",从引用:在ParseFacebookUtils(PFFacebookTokenCachingStrategy.o)_OBJC_CLASS _ $ _ PFFacebookTokenCachingStrategy "_OBJC_METACLASS _ $ _ FBSessionTokenCachingStrategy",从引用:_OBJC_METACLASS _ $ _ PFFacebookTokenCachingStrategy在ParseFacebookUtils(PFFacebookTokenCachingStrategy.o)
ld: symbol(s) not found for architecture …Run Code Online (Sandbox Code Playgroud) 在Android中,我ParseObject使用两个不在Parse类中的局部变量进行子类化.我只需要在本地设置这些变量,而无需将它们保存在服务器上.他们String的名字helper1和helper2吸气者和制定者一样.
它的工作原理罚款所有Android上-我可以使用setHelper1("whatever");,以及getHelper()对我的方法ParseObject的.
我想要做的是在JavaScript中执行相同的操作,因为我想要进行相同的操作ParseCloud并使其返回结果Strings而不在数据库类中创建其他列.
我阅读https://parse.com/docs/js/guide#objects-parse-object和https://parse.com/docs/js/guide#queries-basic-queries但它没有太大帮助,我可以得到它.如何实现?
编辑:
q1.find({
success: function(results){
for (var x in results){
x.helper1 = 'foo';
}
response.success(results);
},
error: function(error){
}
});
Run Code Online (Sandbox Code Playgroud) 当我做:
import sys, json;
import requests
headers = {'Content-Type': 'application/json',
'X-Parse-Application-Id': '...',
'X-Parse-REST-API-Key': '...'}
data = json.load(sys.stdin)
for station in data["data"]:
print station
res = requests.post('https://api.parse.com/1/classes/test4', data=station, headers=headers)
Run Code Online (Sandbox Code Playgroud)
我明白了
{u'city': u'London',
...
}
Run Code Online (Sandbox Code Playgroud)
当我尝试将它发布到Parse.com时,它不是一个有效的Json
{"code":107,"error":"invalid JSON"}
Run Code Online (Sandbox Code Playgroud)
任何JSON验证器都给了我 Error:Strings should be wrapped in double quotes.
如何制作有效的JSON data?
我有一个简单的查询如下:
var getGreaterQuestion = function (gid) {
var query = new Parse.Query(Parse.Object.extend("Question"));
query.equalTo("groupId", gid);
return query.first();
}
Run Code Online (Sandbox Code Playgroud)
我正在准备一个由这个函数组成的数组:
var groupIds = _.range(1, 17);
var groupIdAndRandomNumberPack = _.map(groupIds, function (gid) {
return {groupId: gid, random: Math.random()};
});
var pack = _.map(groupIdAndRandomNumberPack, function (queryItem) {
return getGreaterQuestion(queryItem.groupId, queryItem.random);
});
Run Code Online (Sandbox Code Playgroud)
在pack数组中,有16个不同的"第一"查询用于Question类.
我正在使用以下代码片段运行此查询:
return Parse.Promise.when(pack).then(function () {
console.log("arguments : " + JSON.stringify(arguments));
...
...
);
Run Code Online (Sandbox Code Playgroud)
arguments是我的查询从MongoDB检索数据的结果.
如果我在解析后端运行此查询,则参数json格式如下所示:
{
"0":{QuestionObject},
"1":{QuestionObject},
...
"16":{QuestionObject}
}
Run Code Online (Sandbox Code Playgroud)
如果我在MongoLAB上定义MongoDB的本地解析实例上运行此查询,则会得到以下结果:
{
"0":[
{QuestionObject},
{QuestionObject},
....
{QuestionObject} …Run Code Online (Sandbox Code Playgroud) parse-platform ×10
ios ×4
ios8 ×2
javascript ×2
objective-c ×2
android ×1
baseadapter ×1
express ×1
java ×1
json ×1
mongodb ×1
node.js ×1
php ×1
promise ×1
python ×1
sorting ×1
ssl ×1
swift ×1