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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃殌 Feature: Add $databaseId to documents #3484

Closed
2 tasks done
p4-k4 opened this issue Jul 1, 2022 · 6 comments
Closed
2 tasks done

馃殌 Feature: Add $databaseId to documents #3484

p4-k4 opened this issue Jul 1, 2022 · 6 comments
Assignees
Labels
good first issue Good for newcomers product / databases Fixes and upgrades for the Appwrite Database.
Milestone

Comments

@p4-k4
Copy link

p4-k4 commented Jul 1, 2022

馃敄 Feature description

Not 100% sure if there currently is a way to deal with this (or what is the right way, this might not be a feature and rather an issue) however...

If we have a function that listens 3 levels deep on a database, all being wildcards for e.g:
databases.*.collections.*.documents.*.create

The idea is to be able to access the event data of which currently we can for the collection ID and document ID since that data is embedded, but not in the case of database ID. Is this an oversight or?

When using wildcards, obviously this event data is unknown until the event occurs therefore, we'd want to filter it not partially, but to include all properties that have wildcards on them, including database ID.

Since the introduction of databases in 0.15.0 - The only way I've seen to access the database ID for an event is on the APPWRITE_FUNCTION_EVENT env var where the string looks like this:
databases.DATABASEID.collections.COLLECTIONID.documents.DOCUMENTID.create

I'm performing a string split on this to extract the databaseId but this feels super clunky, let alone whether it's a trustable source?

I asked on Discord and it was mentioned to use a hard coded const in the code of the function. But then what would be the point of listening to events with wildcards if we can't filter that data? The database ID simply cannot be known and since we now have the ability to have multiple databases, we should be able to filter that too.

馃帳 Pitch

A more official way to access the database ID on function events.

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@p4-k4 p4-k4 added the feature label Jul 1, 2022
@p4-k4
Copy link
Author

p4-k4 commented Jul 2, 2022

Come to think of it, and more simply, couldn't a $databaseId key be included in a document? Might provide more consistency across the board.

@r-dev-limited
Copy link

Same question, its nice that you've complicated solution with multiple DBs, but without ENV containing DbId, you've also forced hardcoding this value in functions.

@p4-k4 p4-k4 changed the title 馃殌 Feature: The ability to access event data on server-functions that use wildcards 馃殌 Feature: The ability to efficiently access event data (specifically databaseID) on server-functions that use wildcards Jul 10, 2022
@stnguyen90 stnguyen90 added the product / databases Fixes and upgrades for the Appwrite Database. label Jul 14, 2022
@stnguyen90 stnguyen90 changed the title 馃殌 Feature: The ability to efficiently access event data (specifically databaseID) on server-functions that use wildcards 馃殌 Feature: Add $databaseId to documents Jul 14, 2022
@stnguyen90 stnguyen90 added the good first issue Good for newcomers label Jul 14, 2022
@Meldiron
Copy link
Contributor

With that, can we look at collection response? We currently return databaseId with no dollar.

@p4-k4
Copy link
Author

p4-k4 commented Jul 21, 2022

Whether or not $collection could be $collectionId for consistency and clarity?
Or databases follow suit as $database rather than $databaseId 馃し

@stnguyen90
Copy link
Contributor

I'd prefer $databaseId to make it really clear, but since we have $collection, I vote for $database .

@stnguyen90 stnguyen90 added this to the 1.0.0 milestone Sep 13, 2022
@TorstenDittmann
Copy link
Contributor

This got implemented and released with Appwrite 1.0.0 馃コ

Thank you for your contribution 馃檹馃徎 You can read more here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

6 participants