You are able to duplicate User class by using Parse REST Schema API.
Run this:
curl -X POST \
-H "X-Parse-Application-Id: YOUR_APPLICATION_ID" \
-H "X-Parse-Master-Key: YOUR_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{}' \
http://127.0.0.1:1337/1/schemas/User
Get error: {"code":103,"error":"Class User already exists."}
New User class is created, and if you check parse-dashboard, there are two User classes that exist and work in parallel.
_But if you try to run the curl again now, you will get the expected result._
The user class actually _User, so that's intended that you can create a User class
I see. Actually this is a parse-dashboard issue.
The dashboard is rendering the _User class as User this is maybe why you thought that was a problem ;)
Actually yes. And the problem is that it shows _User data when you click on User class. Parse-server works good, so this is not an issue.
This returns the correct count of users in _User:
curl -X GET \
-H "X-Parse-Application-Id: YOUR_APP_ID" \
-H "X-Parse-Master-Key: YOUR_MASTER_KEY" \
-G \
--data-urlencode 'count=1' \
--data-urlencode 'limit=0' \
http://127.0.0.1:1337/1/classes/_User
This returns 0, instead of the same count, as it is displayed in parse-dashboard, so User class is created, and it is empty:
curl -X GET \
-H "X-Parse-Application-Id: YOUR_APP_ID" \
-H "X-Parse-Master-Key: YOUR_MASTER_KEY" \
-G \
--data-urlencode 'count=1' \
--data-urlencode 'limit=0' \
http://127.0.0.1:1337/1/classes/User
So that's a dashboard error :)
Is there anyway to remove the second User class from view in the Parse dashboard?
Did you try opening weird looking User class in dashboard, and: Edit > Delete this class?
I haven't because my concern is, it will delete the _User class as well!
Well it shouldn't, because you created class named User, and you are concerned about deleting _User... You can create a backup of your DB, try to delete it, if something goes wrong, restore backup.
@dwby Were you able to remove the second User class from view in the Parse dashboard? If yes, how did you do it?
@cipiripper But it won't let me delete the class before deleting all the rows first. And deleting the rows in the duplicate User class deletes the corresponding rows in default User class as well.
@yoterpa Did you try to open mongo shell and remove the class directly from DB? User class is empty in DB, so that restriction you are seeing in dashboard is because of dashboard that mistakenly shows _User data in User class, so it expects all data to be removed... and mongo shell doesn't have this restriction and mixing of class names.
To be honest, I am not sure how I did this... I really don't remember... :) So I am starting to think that I never did remove it, but I removed the whole DB and migrated it again from Parse...
@cipiripper Yes I removed the class directly from DB, but it is still being shown in the Dashboard. Is there anything else I can try other than backup-restore?
@yoterpa Weird... Maybe try to clear cache in browser, restart/reinstall parse-dashboard process? I mean, if you have removed it from DB, then there shouldn't exist anymore... BUT I am not sure what happens if you actually save a User object instead of _User... :)
@cipiripper Clearing browser cache didn't help. As per your suggestion, I tried adding a User object from dashboard which successfully creates a new object, but as soon as I refresh the tab it disappears. I checked the db in mongo-shell and found that User class got created again. :(
Yes, well that's how parse works... If there is no class, it creates it... Just don't create new Users, but Parse.User or _User... and remove all User objects and class from db. I guess that this must work...
I have already deleted the User class from mongo-shell, cleared browser cache, restarted parse-server and dashboard, but the issue still persists.
@yoterpa How did you delete it? Using drop() or remove()? Try drop()? Also be sure that there is no after delete trigger that re-creates the user, and remove all User relations if any...
I'm out of ideas. Good luck. :)
I used drop(). There is no after delete trigger. There is a relation but to _User class, NOT User class.
Thanks a lot for your help. :) I will try something else.
You will also probably need to remove the User document from the _SCHEMA collection and restart your server and dashboard
@steven-supersolid That worked!! Thanks :) I did not even have to restart the server or the dashboard.
The mongo shell command that I used:
db.getCollection("_SCHEMA").deleteOne({_id: {$eq:"User"}})
Most helpful comment
You will also probably need to remove the
Userdocument from the_SCHEMAcollection and restart your server and dashboard