parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Add unique fields only capability to schema

Open fn-faisal opened this issue 4 years ago • 7 comments

New Pull Request Checklist

  • [x] I am not disclosing a vulnerability.
  • [x] I am creating this PR in reference to an issue.

Issue Description

Add an option to ignore parse default fields while creating a schema.

Related issue: https://github.com/parse-community/parse-server/issues/6059

Approach

Add request object serialisation to the create schema endpoint such that when a transform option is provided either in the request body or params, parse server performs the required serialisation before handing the object over to controller for saving. For this issue, only one serialisation option has been added i.e. ignoreDefaultFields . ignoreDefaultFields option removes the default field from request object before saving schema and no error is sent to the requesting client app.

eg body options:

{
    "options": {
        "ignoreDefaultFields": true
    },
    "className": "Another",
    "fields": {
        "objectId": {
            "type": "String"
        },
        "name": {
            "type": "String"
        }
    }
}

eg response:

{
    "className": "Another",
    "fields": {
        "objectId": {
            "type": "String"
        },
        "updatedAt": {
            "type": "Date"
        },
        "createdAt": {
            "type": "Date"
        },
        "name": {
            "type": "String"
        },
        "ACL": {
            "type": "ACL"
        }
    },
    "classLevelPermissions": {
        "find": {
            "*": true
        },
        "count": {
            "*": true
        },
        "get": {
            "*": true
        },
        "create": {
            "*": true
        },
        "update": {
            "*": true
        },
        "delete": {
            "*": true
        },
        "addField": {
            "*": true
        },
        "protectedFields": {
            "*": []
        }
    }
}

eg query params: http://localhost:1337/parse/schemas/Another?ignoreDefaultFields=true

TODOs before merging

  • [x] Add test cases
  • [x] Add entry to changelog
  • [ ] Add changes to documentation (guides, repository pages, in-code descriptions)
  • [ ] Add security check
  • [ ] Add new Parse Error codes to Parse JS SDK
  • [ ] ...

fn-faisal avatar May 15 '21 19:05 fn-faisal

Thanks for this PR. Can you please reference the corresponding existing issue or create a new issue?

mtrezza avatar May 16 '21 08:05 mtrezza

@mtrezza this is in reference to the issue below. https://github.com/parse-community/parse-server/issues/6059

fn-faisal avatar May 17 '21 08:05 fn-faisal

I added the issue link to your initial post and also did some reformatting.

mtrezza avatar May 17 '21 12:05 mtrezza

Codecov Report

:x: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review. :white_check_mark: Project coverage is 93.91%. Comparing base (bdf73a0) to head (38d0e63). :warning: Report is 1448 commits behind head on alpha.

Files with missing lines Patch % Lines
src/Routers/SchemasRouter.js 94.44% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #7388      +/-   ##
==========================================
- Coverage   93.92%   93.91%   -0.01%     
==========================================
  Files         181      181              
  Lines       13209    13235      +26     
==========================================
+ Hits        12406    12430      +24     
- Misses        803      805       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 17 '21 12:05 codecov[bot]

⚠️ Important change for merging PRs from Parse Server 5.0 onwards!

We are planning to release the first beta version of Parse Server 5.0 in October 2021.

If a PR contains a breaking change and is not merged before the beta release of Parse Server 5.0, it cannot be merged until the end of 2022. Instead it has to follow the Deprecation Policy and phase-in breaking changes to be merged during the course of 2022.

One of the most voiced community feedbacks was the demand for predictability in breaking changes to make it easy to upgrade Parse Server. We have made a first step towards this by introducing the Deprecation Policy in February 2021 that assists to phase-in breaking changes, giving developers time to adapt. We will follow-up with the introduction of Release Automation and a branch model that will allow breaking changes only with a new major release, scheduled for the beginning of each calendar year.

We understand that some PRs are a long time in the making and we very much appreciate your contribution. We want to make it easy for PRs that contain a breaking change and were created before the introduction of the Deprecation Policy. These PRs can be merged with a breaking change without being phased-in before the beta release of Parse Server 5.0. We are making this exception because we appreciate that this is a time of transition that requires additional effort from contributors to adapt. We encourage everyone to prepare their PRs until the end of September and account for review time and possible adaptions.

If a PR contains a breaking change and should be merged before the beta release, please mention @parse-community/server-maintenance and we will coordinate with you to merge the PR.

Thanks for your contribution and support during this transition to Parse Server release automation!

mtrezza avatar Sep 03 '21 00:09 mtrezza

@fn-faisal Could you please resole the conflicts? Is this PR ready for review?

mtrezza avatar Sep 10 '21 11:09 mtrezza

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!