Jake T.
Jake T.

Reputation: 4378

Parse - manually set an object id

I have two versions of my app on parse, a test and a live version.

I created a new class and created an instance of the class on each app. Inside of my iOS app, I call that instance to obtain a bunch of strings to use through out the app. Unfortunately, I decided to query by object id, and I forgot to replace the object id of the test app version with the id of the live app version... therefore, the query returns no object, and my strings are not set.

I'm afraid this won't be an issue Apple will accept for expedited release. It seems my best bet is to create the object with the same object id, so that it gets pulled up. That won't require any update on the app store.

Is there ANY way to do this? I found a createWithoutData method, but it doesn't work create an instance, only references an existing instance. I tried the following, but it returned the error "object not found for update" when I tried to save it.

// Create a pointer to an object of class Point with id dlkj83d
var Point = Parse.Object.extend("Point");
var point = new Point();
point.id = "dlkj83d";

I even thought to try a loop that creates objects until it finds one with the right id, but you don't get an assigned id until the object is saved, apparently, and the request limit makes that extremely unlikely to be fruitful.

I can't find any Parse support numbers to reach, it all just says to ask the community... I feel like I should be able to find a support number and ask someone to either change my existing id or create a new one manually for me. It shouldn't be impossible to do. Please, let me know if you know of a way to handle this!

Thanks for any and all tips.

Upvotes: 4

Views: 4070

Answers (1)

Meghs Dhameliya
Meghs Dhameliya

Reputation: 2454

Parse not allow to set object Id Manually or Programmatically although you can change the existing ObjectID with following step

1)Take backup of specific class you want to change ObjectID.

2)Backup file will be in .json format open in text-editor.

3)Find the ObjectID and Replace with your new ObjectID.

4)Import this in Parse thats all.

i hope this will help.

Edit - This is still possible with Parse-Server, although it must be done directly through your Database, rather than Parse-Server. There is no import / export tool built into the dashboard, and you are still not allowed to set or modify objectIds of existing objects. You can, however, import .bson and .json data with an _id field set, allowing you to explicitly set objectIds. While these objectIds can be whatever value, it is highly recommended you conform to Parse-Server's schema and ensure you are not creating any duplicate Ids.

Upvotes: 11

Related Questions