Skip to content

Officially expose MongoDB client #8786

Open
@mtrezza

Description

@mtrezza

New Feature / Enhancement Checklist

Current Limitation

Parse Server uses a richer interface to interact with the database than it exposes for developers to use. For example upserting (upsertOneObject), mass-updating by query (updateObjectsByQuery) or findOneAndUpdate. These are currently only accessible via:

  • the internal database adapter, for example Parse.Server.database.adapter.findOneAndUpdate
  • the higher level Parse.Server.database.update which adds some convenience, like supplying the schema for the target class and transforming high-level Parse references to raw MongoDB references

Given these method's versatility and efficiency, we can assume that they are widely in use. Especially since the Parse Server configuration has been made more accessible with Parse.Server in #7869.

As an example for efficiency consider the case of upserting an object:

  • With he public interface an upsert requires 1 unique index, 1 write request, catching the error if the object exists and then 1 update request.
  • With the internal interface an upsert requires 1 upsert upsertOneObject request.

However, these methods are all internal. Changing them would not be considered breaking changes and it wouldn't even be in the changelog. It is even suggested that they may be removed if possible:

// Hopefully we can get rid of this. It's only used for config and hooks.
upsertOneObject(

Feature / Enhancement Description

Parse Server should officially expose a method in Cloud Code similar to the Parse.Server.database.update method. Exposing Parse.Server.database.update directly would likely be unpractical, since the method is not well structured in its design and is used internally throughout the code. It could be available in Cloud Code via something like await Parse.Cloud.Database.execute({ ... }).

Availability in the Parse JS SDK is out of scope for this feature, see also #8787.

Example Use Case

Metadata

Metadata

Assignees

No one assigned

    Labels

    bounty:$100Bounty applies for fixing this issue (Parse Bounty Program)type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions