samuelgozi/firebase-firestore-lite

Emulators?

benregn opened this issue · 8 comments

Thank you for your effort of creating slimmer alternative to the official SDK!

Do you think this library will be able to use the Firebase emulators? Or maybe it can already?

I haven't thought about it.
I read the official docs, and it seems like a small modification it will work.
Hopefully, I'll get this to work today, but it will only release in 1.0. But I'll try to provide a temporary fix in a comment.

Ok, all changes were made in order for this to work on v1.0.
This is how it would look:

const db = new Database({
	projectId: 'sandbox',
	host: 'localhost:8080',
	ssl: false
});

If you can't wait, then here is a temporary fix.

const db = new Database({
	projectId: 'sandbox',
});

db.endpoint = db.endpoint.replace('https://firestore.googleapis.com', 'http://localhost:8080');

I will leave this issue open until v1 is released, in order to receive feedback.
If you think it should be implemented in a different way, or something doesn't work, don't hesitate to comment.

PS: you can try v1.0 by using the v1.0.0 branch.

Awesome! Thanks for working on a solution so quickly, I'll take it for a spin 👍

I tried the temporary fix you proposed but when I try to query a collection, db.reference(`users/${userId}/subcol`).query().run(), I get an error Payload isn't valid for request. Any ideas or suggestions about how to help debug it?

Sounds like the emulator is not complete for the REST API.
Just to be clear. It does work with the live servers, right?
I didn't want to install Java(for the emulator)... but it seems like I don't have a choice...

I've updated many parts of the API to use transactions that should be supported by the Emulators.
If you are still looking interested, please let me know if the update makes things better.