-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Officially expose MongoDB client #8786
Comments
Thanks for opening this issue!
|
I'm revising my suggestion. After playing around with For example, a date value has to be supplied in a different format (JavaScript Date object, Parse JSON with date ISO string) depending on whether it's set in the I don't think these API should be officially exposed, because:
So instead I'm suggesting to expose the MongoDB adapter in a more convenient way. It should give total freedom of what command to execute, without any Parse <-> MongoDB transformations. This is in line with the MongoDB aggregation pipeline which also does not (should not) apply any transformations. |
@mtrezza here a simple "trick" to access the mongo client, may be it should be exposed under a specific method ? An easy one i guess finally here export const getMongoClient = async (): Promise<GetMongoClient> => {
await parseServer.config.databaseController.adapter.connect()
return {
db: parseServer.config.databaseController.adapter.database,
client: parseServer.config.databaseController.adapter.client,
}
} |
I was thinking about an officially documented method within the |
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
) orfindOneAndUpdate
. These are currently only accessible via:Parse.Server.database.adapter.findOneAndUpdate
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 referencesGiven 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:
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:
parse-server/src/Adapters/Storage/Mongo/MongoStorageAdapter.js
Lines 586 to 587 in fe02d3e
Feature / Enhancement Description
Parse Server should officially expose a method in Cloud Code similar to the
Parse.Server.database.update
method. ExposingParse.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 likeawait Parse.Cloud.Database.execute({ ... })
.Availability in the Parse JS SDK is out of scope for this feature, see also #8787.
Example Use Case
The text was updated successfully, but these errors were encountered: