1

I'm writing a backup job, and need to fetch all classes in Parse-server, so I can then query all rows and export them.

How do I fetch all classes?

Thanks

BlackMouse
  • 4,442
  • 6
  • 38
  • 65

1 Answers1

5

Query the schemas collection.

GET /parse/schemas

Probably need to use the masterkey on the query. Not sure what language you're writing your job in but should be simple for you to create a REST query or create a node.js script and use the javascript/node api

--Added after comment below --

var Parse = require('parse/node').Parse;
Parse.serverURL = "http://localhost:23740/parse";
Parse.initialize('APP_ID', 'RESTKEY', 'MASTERKEY');

var Schema = Parse.Object.extend("_SCHEMA");
var query = new Parse.Query(Schema);

query.find({
  success : (results) => {
  console.log(JSON.stringify(results));
},
 error : (err) => {
 console.log("err : " + JSON.stringify(err));
 }});
coweye
  • 164
  • 9
  • Thanks for reply. How do you write this query? – BlackMouse Jun 25 '16 at 12:48
  • Thanks for the posted code. I see the logic, but the code return an empty error however. Do you need to call it with the REST api maybe? – BlackMouse Jun 27 '16 at 06:46
  • 2
    Yeah I tried using the REST API there using this request "GET http://localhost:23740/parse/classes/_SCHEMA X-Parse-Application-Id: APP_ID X-Parse-Master-Key: MASTER_KEY" but it gives a 500 internal server error. Maybe best thing would just just go straight to Mongo itself instead of through parse for getting the schema then? – coweye Jun 27 '16 at 13:13
  • 1
    _SCHEMA is not per se a class, and you should not rely on that (as it may get removed anytime). The right way is to call the `/schemas` endpoint, so if your serverURL is "http://localhost:23740/parse" that would be "http://localhost:23740/parse/schemas" – flovilmart Jul 16 '16 at 16:53