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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align syntax with firebase/firebase-dart where possible (firestore) #16

Open
grundid opened this issue Jun 7, 2018 · 5 comments
Open

Comments

@grundid
Copy link

grundid commented Jun 7, 2018

This is more of a discussion issue ;)

I'm using Dart on the client (AngularDart) and on the backend (cloud functions). Sometimes I want to try a functionality on the client and also on the backend and see what works best.
For this I have to rewrite the firestore code since there are some minor differences between your code and the code in the client library.

Here is an example of a query in firebase-dart:

firestore.collection("list").where("field", "==", value).get();

where as in firebase-admin-interop a query looks like this:

firestore.collection("list").where("field", isEqualTo: value).get();

There are many other differences especially with DocumentData where your interop library adds more type safety whereas firebase-dart uses only Maps with dynamic values.

Adding documents in firebase-dart:

firestore.collection("list").add({"name": "test"});

in firebase-admin-interop:

DocumentData data = new DocumentData();
data.setString("name", "test");
firestore.collection("list").add(data);

It would be great if we could have some common API and only swap the implementation when needed. Also great for code reuse.
What do you think?

@pulyaevskiy
Copy link
Owner

Thanks for bringing this up. I agree that it would make more sense if Firestore libraries shared common interface.

Note that there is also cloud_firestore package for Flutter which also uses it's own interfaces.

I used the Flutter package interface as a reference in some cases. For instance the DocumentQuery.where method maps to the one in the Flutter plugin. So in this regard I did try to conform to a certain interface.

Though I must admit I didn't follow through there.

I can imagine we'd need some sort of firestore_core package with interfaces for all Firestore objects (DocumentReference, CollectionReference, Query, etc) and then make all other libraries use those to have platform specific implementations.

This would definitely be nice to have. But we need collaboration with authors of other libraries in order to achieve this.

I'm gonna try and ping @Janamou @kevmoo (Firebase Web) and @kroikie @collinjackson (Flutter) to hopefully get some input on this.

@kevmoo
Copy link

kevmoo commented Jun 8, 2018

I'd love to align here, too. I pondered for a while creating a "mono repo" for https://github.com/firebase/firebase-dart – to separate out the VM vs browser libraries. That could also let us create a "core" or "interfaces" package we could share.

Sadly, I have very little time to work on such things...

@alextekartik
Copy link
Contributor

The underlying native APIs (Web, Node, Flutter) are still in flux (There are almost 3 different SDKs for javascript: browser, Node.js, admin sdk) and some features are different (Query.select not supported on Flutter/Browser). The API are quite similar and I think it is getting there so hopefully something might pop up one day!.

I have my opiniated abstraction layer that tries to sanitize the API if you need something right now (Flutter untested and still missing important feature like startAt(snaphot) and FieldValue) for now mainly firestore oriented, undocumented...

@pulyaevskiy
Copy link
Owner

@grundid

you might be interested in this thread flutter/flutter#16186 . Also leaving this here as a cross reference.

@gazialankus
Copy link
Contributor

Here's one more example of a mismatch. Use serverTimestamp differs in different Dart Firestore clients:

In AngularDart: FieldValue.serverTimestamp()
In here: Firestore.fieldValues.serverTimestamp()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants