-
Notifications
You must be signed in to change notification settings - Fork 4.4k
🚀 Feature: sdk for setup single database of project by default #5773
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
Comments
Trying to understand this concept. So you are suggesting that we should be able to set the default database in your project while initializing your client right? If that's the case, then I can see why this can be useful, but it seems like a not-so-necessary thing. You're absolutely right when saying that most projects use a single DB, but countless others use multiple as well. This can be countered by making the Might be completely wrong though. Just my opinion! |
Ease of use |
anyone can use single database or multi project and in create functions use documentId optional (if null use ID.unique() default) yes |
You can see that in an older version of Appwrite, this for example there wasn't even a layer of Database per project. The Database layer was added in version 0.15, check here more about that. What I think can be a way around it is to wrap those functions in some small helper. For example: class ProjectDB {
String databaseID;
Databases database;
ProjectDB({this.databaseID = '', Client client}) {
database = Databases(client);
}
Future<models.DocumentList> listDocuments({required String collectionId, List<String>? queries}) async {
return await databases.listDocuments(
databaseId: databaseID,
collectionId: collectionId,
queries: queries
);
}
} Although I agree that it would be nice to have something like you've suggested, like: databases.setDefaultDB(databaseId);
// Use Default
await databases.listDocuments(
collectionId: collectionId,
queries: queries
);
// Specify DB
await databases.listDocuments(
databaseId: databaseID,
collectionId: collectionId,
queries: queries
);
|
Reading @byawitz comment made it more clear to me. +1 from me. |
@TechComet, thanks for raising this! 🙏🏼 We actually had a way to set the databaseId for all requests in the past, but this lead to more confusion especially when trying to explain how creating databases worked (with a server SDK). That's why we changed the SDKs to explicitly require a databaseId parameter. This is a bit more repetitive, but being explicit avoids confusion. As @byawitz mentioned in #5773 (comment), you're more than welcome to create a wrapper in your code. |
Uh oh!
There was an error while loading. Please reload this page.
🔖 Feature description
Most projects use a single database
I write example for getDocument but I talk for all functions
and write class for call function direct with default client
samething like this class but inside appwrite package
https://pastebin.com/raw/txMGE7Bh
🎤 Pitch
example in Dart
in get document if use default database
databaseId is null
database.getDocument(collectionId: 'collectionId', documentId: 'documentId');
in get document if use other database
database.getDocument(databaseId: 'other databaseId', collectionId: 'collectionId', documentId: 'documentId')
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: