How could I predefine my schemas in the parse server cloud side?

Hello,

I am new to Parse Server, and now trying out the parse-server-example, I just would like to know how could I define my schemas beforehand in the cloud side, so when do the first post request via rest api, it will follow the valiadation of my schemas.

I searched docs but only found below:

And seems no related info for the parse-server cloud side:

Any one could please kindly help? Thanks a lot.

I have also found this link, adding a schema via rest api. But I just would like initialize my schemas when parse server start (also need check if the schemas already to avoid repeating adding the same schemas).

Hi @xeoshow and welcome! Predefined schemas are currently not supported, however @sadortun and @Moumouls have almost finished their PR which will make this feature part of the V5 release.

1 Like

Hi Daniel,
Got it, thanks so much again for your kind help! :slightly_smiling_face:
And another question: when will parse server V5 be released? And the V5 codebase is a big change from V4 or totally rewrite from scratch?

We are expecting V5 in the next month or so. V5 does contain some breaking changes and security improvements, but the core Parse Server will be mostly the same :blush:

Hi Daniel,
Looks like the Examples there got 404 error:

Examples:

How to use it in for Parse-server initialization :
https://github.com/sadortun/GoPlan-app/blob/feat-holding-history/backend/src/server.ts#L73

How to define your schemas :
https://github.com/sadortun/GoPlan-app/tree/feat-holding-history/backend/src/Migrations/schemas

You would have to ask @sadortun, that’s his repo :blush:

Hi Guys,

Best way to get you started is to have a look at our open source project using it

You can add this to your config

And add your schemas:

We plan to implement unique indexes soon too.

For this you’ll need to use the code from the pr_migration branch from :

Note that the master branch have other currently PRs pending review. So it’s up to you, but using the pr_migration branch is probably a bit more stable.

PLEASE OPEN ISSUES ON OUR FORK IF YOU FiND ISSUES OR HAVE SUGGESTIONS FOR THE MIGRATION PR

Enjoy!

1 Like

Warm community and great thanks!

Found below schema definition part, and a further question: could it be possible that we generate the rest api document based on this schema definition with adding comments info for all fields?

So when schemas changes, we could easily resync the api doc with further details for all classes.

Please note the fork is now outdated. Please check the main repo for examples.

As for docs. It’s a nice idea, feel free to submit a PR !

Hello @sadortun and community,

Just would like to know about another question : If I have already got many mangodb collections, any way to automatically generate corresponding schemas for them?

I am seriously considering migrating my project to parse server, and this is a big problem for me.

Thanks so much!

Hey @xeoshow

Unfortunately, you need to create theses files manually. The good news, is that after you made the first one, creating the rest is really easy.

I migrated another app few weeks ago with ~25 schemas and it took me around an hour.

ParseServer will also give you console warnings if you set strict:true about any missing or misc configured fields.

1 Like

Hi @sadortun ,

Just managed to get time to try this out, and I found there is 5.0.0-beta.3 tag (chore(release): 5.0.0-beta.3 [skip ci] · parse-community/[email protected] · GitHub) released, so could I use this latest beta version to try without using the previous pr_migration branch?

Thanks so much.

Yes, it should be in the alpha/beta branch

1 Like

Have you tried Google :sweat_smile: ?

Hi @sadortun ,

Sorry for the bothering, I have searched and do found below usage, along with the esm method (our old project used this).

"type": "module"

While I just do not plan to use typescript (not familar with it, and js is better for old project migration), and met below error:
a. “type”: “module”:

b. esm:

Node version is v14.16.0.

Need your futher help, thanks so much!

Mmmm, Parse use Flow, which is a a thing similar to Typescript. I’m not sure in your case if you’re using the original Parse sources that include Flow.

I’m probably not the best to help you with this. It seems like an issue with project configuration, but I’m not sure.

Hi @sadortun ,

Problem resolved and seems found a bug:

For the User (_User) schema (Other external table schemas are normal), it could be added to the collection even if data is not confined to the schema (the schema strict: true):


As shown above, aaa and bbb is not defined in the schema, while the data could be added to the _User collection.

For other schemas and corresponding collections, they will get addField error response and the data could not be added.

Hi!

Glad to see you got your project working !

Currently the strict:true doesn’t prevent users with permissions to create fields. But only warns to the console when there is a discrepancy.

See CPL addField if you want to block access.

In a future version, strict mode could be more severe, but this willl be up for discussions in a later release.

1 Like

Got it and thank you v much!

1 Like