Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add defined schema docs #863

Closed

Conversation

Moumouls
Copy link
Member

@Moumouls Moumouls commented Feb 20, 2022

Add defined schema docs.

See #872

@Moumouls
Copy link
Member Author

Moumouls commented Feb 20, 2022

@sadortun if you want to take a look, feel to suggest some commit changes from github UI 🙂

- `delete`: Delete permission
- `protectedFields`: Control get permission at field level

You can set each CLP field with options to add a first strong security layer. This security layer will be applied on the Parse Class and all Parse Objects into this class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"into this class"? Do you mean sub classes?


## CLP Protected Fields Key

This CLP key is powerful and need some additional explanation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line can be removed, it doesn't seem to provide any relevant info. Maybe instead a sentence about what this is (used for).

}
```

Listed keys under `*` will be protected from all users. Don't worry by default, `authData`, `emailVerified`, `password` are protected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "don't worry"

```

Listed keys under `*` will be protected from all users. Don't worry by default, `authData`, `emailVerified`, `password` are protected.
But here for example we protect `username` from all users. So user A, even authenticated will not be able to get the `username` of a user B.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is "here"? There is an example before and one after.

```

Listed keys under `*` will be protected from all users. Don't worry by default, `authData`, `emailVerified`, `password` are protected.
But here for example we protect `username` from all users. So user A, even authenticated will not be able to get the `username` of a user B.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The references "user A", "user B" seem to not be used anywhere else? If so, just simplify this to something like "a user cannot ... of other users".


## strict

You can set the `strict` option to `true` if you want parse-server to delete removed classes from your schemas from your database. Data stored in removed classes will be lost.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Parse Server"

Could you rephrase "from your schemas from your database", may be confusing


You can set the `strict` option to `true` if you want parse-server to delete removed classes from your schemas from your database. Data stored in removed classes will be lost.

`strict` is default to `false`. If you often change your schemas be aware that you can have some stale classes in your database. You will need to delete these classes manually.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"By default strict is false.

"You can have stale..." sounds like it's permissible. I think you want to say that the stale classes are unwanted and may remain?


## deleteExtraFields

You can set the `deleteExtraFields` option to `true` if you parse-server to delete removed a class field from your database. Data stored in the removed field will be lost.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if you want Parse Server to..."

"Delete remove" - a typo?


You can set the `deleteExtraFields` option to `true` if you parse-server to delete removed a class field from your database. Data stored in the removed field will be lost.

`deleteExtraFields` is default to `false`. Be aware that some stale fields could exists in your database. You will need to delete these fields manually.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here rephrasing


## beforeMigration

A function called before parse-server performs schema updates based on the `definitions` option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use "Parse Server" when you refer to the product, don't use "parse-server" unless you are referring to the repository.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still open

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still open


Note: If you update CLP you do not need to update Parse Objects. CLP is a security layer at Class Level not Object Level. For Object Level permission you can take a look to ALCs. You can use CLPs combined to ACLs to deeply secure your Parse Server.

## CLP Key Options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest replacing globally key with either parameter or attribute depending on the context.

Currently parameter seems to be more generalized as config keys

https://docs.parseplatform.org/parse-server/guide/#usage

// and then create the field with the new type
recreateModifiedFields: true,
// If true, Parse will delete non defined fields on a class. (Core fields are never deleted)
deleteExtraFields: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theses 2 parameters should be false by default in the example to avoir a user copy-pasting the example config have it's data deleted unintentionally.

@Moumouls
Copy link
Member Author

Moumouls commented Mar 5, 2022

@sadortun @mtrezza requested changes performed. Feel free to use the Github commit suggestion feature if you some new changes suggestions, then i can apply easily your changes :)

@Moumouls Moumouls requested a review from mtrezza March 5, 2022 09:37
Copy link
Contributor

@sadortun sadortun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

Only thing could be to add some Bold/red font on dangerous options


You can set the `recreateModifiedFields` option to `true` if you want Parse Server to clean field data before Parse Server update the field type when you change the type of a field (ie: from `String` to `Number`). Data stored on the modified field will be lost.

`recreateModifiedFields` is default to `false`. Be aware that if you do not perform some data migration, you can result with data type inconsistency on modified field.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe adding some Bold for ?

Be aware that if you do not perform some data migration

@Moumouls
Copy link
Member Author

@sadortun i added bold, @mtrezza since Parse V5 was released, what do you think about merging this one ?

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General feedback: the texts are quite verbose. Try to condense essential information into few words. Try to use as few lines as possible, instead of many lines with only a few words per line, that makes it easier to read and uses less space. For example:

// Here your Parse Server is ready
// with schemas up to date

// Just a code example if you want to expose
// an endpoint when parse is fully initialized

can be condensed into

// Parse Server is ready with up-to-date schema

- `role:MyRole`: If you have already created a Parse Role, you can use your created Parse Role (ie: `MyRole`) in CLP keys.
- `requiresAuthentication`: If true an authenticated user will have the permission.
- `*`: Everybody has the permission
- `{}`: if you set the CLP key with `{}` like `create: {}` only calls with your Parse Server Master Key will have the permission
Copy link
Member

@mtrezza mtrezza Mar 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"`role:<roleName>`: If you are making use of Parse Roles you can set the permission based on a role."
...
"If you set the CLP key to `{}`" ... "calls with the Parse Server master key will"

Available options for CLP parameters:

- `role:MyRole`: If you have already created a Parse Role, you can use your created Parse Role (ie: `MyRole`) in CLP keys.
- `requiresAuthentication`: If true an authenticated user will have the permission.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If set to `true`, only authenticated users"

Available options for CLP parameters:

- `role:MyRole`: If you have already created a Parse Role, you can use your created Parse Role (ie: `MyRole`) in CLP keys.
- `requiresAuthentication`: If true an authenticated user will have the permission.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If set to `true`, only authenticated users"


This CLP parameter allows you to restrict access to fields to specific Parse users.

We will take the Parse User Class as example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as an example:"


This CLP parameter allows you to restrict access to fields to specific Parse users.

We will take the Parse User Class as example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as an example."


`recreateModifiedFields` is default to `false`. **Be aware that if you do not perform some data migration, you can result with data type inconsistency on modified field.**

On production a good practice could be to create a new field with your new type, and then create a Parse Cloud Job to migrate old field data to the new created field.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Good practice would be to create a new field with a new type" ... "to the newly created field."


## lockSchemas

You can set the `lockSchemas` option to `true` if you want to to prevent any `Parse.Schema` manipulation outside of the Defined Schema feature. If this options is `true` any create/update/delete request to `Parse.Schema` will be denied. You will not be able to manipulate `indexes`, `classLevelPermissions`, `fields`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if you want to prevent any schema manipulation and to lock the schema as defined in the Parse Server configuration." ... "any create, update and delete request will be denied by the Parse Server API, even with the master key."

You can delete the following sentence "This option help to keep " as it does not provide any additional information.


## lockSchemas

You can set the `lockSchemas` option to `true` if you want to to prevent any `Parse.Schema` manipulation outside of the Defined Schema feature. If this options is `true` any create/update/delete request to `Parse.Schema` will be denied. You will not be able to manipulate `indexes`, `classLevelPermissions`, `fields`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if you want to prevent any schema manipulation and to lock the schema as defined in the Parse Server configuration."


## beforeMigration

A function called before parse-server performs schema updates based on the `definitions` option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still open


## beforeMigration

A function called before parse-server performs schema updates based on the `definitions` option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still open

@stephannielsen
Copy link

stephannielsen commented May 2, 2022

Maybe not the best place to ask but as there is no official documentation available yet:

  • Can we define on schema levels Array of Pointers of a specific class? This PR does not mention this and from some tests it seems that if you specify Array as type in the schema, anything is accepted as array content.
  • It would be nice if the documentation could include some examples on how to use beforeMigration and afterMigration hooks. I am not sure how I could leverage them to migrate data.

@mtrezza
Copy link
Member

mtrezza commented May 2, 2022

Thanks for the feedback to the docs, maybe @Moumouls can add this to the PR?
To your first point, the best place to ask is our community forum.

@Moumouls
Copy link
Member Author

Moumouls commented May 2, 2022

thanks, @stephannielsen for your feedback I'll quickly answer to your question. Parse is not currently able to type the content of Array. Anything could be stored in the Array. You can use the beforeSave Parse Cloud hook to prevent users saving anything other than the desired pointers.

If you use the GraphQL API. You can use the "inline fragment" graphql feature to automatically get data from the pointer array.

https://community.parseplatform.org/t/type-arrayresult-must-have-a-selection-of-subfields-error/847/2?u=moumouls

for example ... on MyPointerClass { id aField}

@stephannielsen
Copy link

Thanks @Moumouls and @mtrezza for your quick replies.

I already expected that Parse can't type array fields and that triggers would allow me to validate incoming data. Thanks for the quick confirmation.

@RahulLanjewar93
Copy link
Contributor

Hey, just had a quick question, since the documentation isn't updated yet. Can we have unique indexes according to the recent merge?

Thanks.

@mtrezza mtrezza changed the title feat: defined schema docs docs: defined schema docs May 12, 2022
@mtrezza mtrezza changed the title docs: defined schema docs docs: add defined schema docs May 12, 2022
@mtrezza
Copy link
Member

mtrezza commented May 12, 2022

If anyone wants to pick up and finish this PR (see the review comments, just grammar and style corrections), please feel free to do so, so we can merge this chapter about defined schema into the docs. You will probably have to open a new PR, then we can close this one.

I have added a description to this PR and created issue #872 to track this.

@Moumouls
Copy link
Member Author

@mtrezza any chance to update your comments using the commit suggestion feature ? then I'll be happy to apply all your suggestions 🚀

@Moumouls
Copy link
Member Author

closing in favor of #912

@Moumouls Moumouls closed this Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants