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

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

Hi @sadortun,

For the fields part, is it conform to the JSON Schema specification as shown at below link? Thanks a lot.

Hello @davimacedo @sadortun @dblythy ,

Just would like to know the schema difference between the parse server and the http://json-schema.org/, or they are just the same or similar?

If they are the same, we could easily use tools to extract the json schema from the json sample data (like Best JSON to Jsonschema Converter or Free Online JSON to JSON Schema Converter), which is a big plus for parse server.

Great thanks for any help!

I am not familiar to json-schema, but Parse Server has its own schema and I guess they are probably different.

Hi @davimacedo ,

Thanks for reply. They are different while seems quite similar. Json-schema is the standard specification in this area to some extent, there are some tool chains already, like:

ā€¦

Just some idea: if parse server could adapted to support json-schema, many open source projects could be helpful out of the box to make parse server version 5 to be more stronger and easy to use.

Thanks for reading this post :slight_smile:

1 Like

Hello, @sadortun

How about the unique indexes implementation now? Thanks a lot.

We plan to implement unique indexes soon too.

Itā€™s still something we want to add, but we donā€™t have any specific date for now.

Is there any way we can implement unique indexing, or is there any workaround available?

Hi @RahulLanjewar93 ,

This feature is now supported by Parse Server. Documentation is not merged, i see that you commented the PR.

Iā€™m posting the PR link here if anyone wants to use this feature : docs: add defined schema docs by Moumouls Ā· Pull Request #863 Ā· parse-community/docs Ā· GitHub

An example from a personal repo: parse-next-mono-starter/server.ts at master Ā· Moumouls/parse-next-mono-starter Ā· GitHub

@xeoshow also if you are interested by the feature :slight_smile:

2 Likes

Hi @Moumouls,

So the unique indexes implementation is included now? From which version?
Thanks v much.

Best regards, Jason

ahaha sorry for the misunderstanding @xeoshow .

The Defined Schema feature is now supported out of the box since 5.0 :slightly_smiling_face:

But the unique indexes are still not currently supported.

Hello @Moumouls ,

Just would like to know if the unique indexes are supported in the latest version, such as 5.4.0?

Thanks a lot.

Best regards, Jason

Hi @xeoshow , unique indexes/custom indexes are still not supported.

But, in my company we encountered an issue with the current interface of Parse Indexes, there are too restrictive. So maybe Iā€™ll push a PR to allow a ā€œnon-restrictive modeā€ to allow a developer to create any indexes without validation or transformation. The goal is to send the index config directly to the DB.

Note: Official Defined Schemas docs are now released: Defined Schema Guide | Parse

@Moumouls Thanks for kind help.
Actually I met the problem described in this post:

I think maybe the simple solution is to create the unique indexes on the related fields, which should be ā€œrestrictive modeā€, otherwise that bug still will happen.

BTW, we have already used the indexes in our schemas similar as below, but it looks like NOT unique index?

indexes: {
    tagsIndex: { tags: 1 },
    // The special prefix _p_ is used to create indexes on pointer fields
    cityPointerIndex: { _p_city: 1 },
    tagAndCityIndex: { _p_city: 1, tags: 1 },
  },

Any further help is highly appreciated.

Best regards, Jason

@xeoshow, the above index, are just normal indexes. Unique is a special config on the index definition.

Currently there is no good solution, Iā€™ll keep you updated once a PR is sent :slightly_smiling_face:

1 Like

You can create standard indexes or unique indexes by accessing the adapter directly. I show code for how to do this here:

There are other types of indexes you are not able to create as @Moumouls pointed out, for those, I typically run a script to add them to the DB directly.

1 Like

Hello,

For the latest version 6.1.0, is the unique index feature supported now? Thanks a lot.