node-viewmodel
node-viewmodel copied to clipboard
Support for firestore
I've added Google's Firebase Firestore as a data source/destination in view model. If there is anything else that needs to be implemented or supported to get this database into the package just let me know.
wow cool. Is there a way to have tests?
just another idea: For simple queries, would it be possible to map mongodb like queries? I.e. this: aRepo.find({aProp: 'aValue'}, would be mapped to this: aRepo.find(['aProp', '==', 'aValue'], ?
Looks great indeed! In addition to tests ( let us know if you need any help setting those up ), could you please adjust the documentation to use ES5 syntax, for it to be in tact with the rest?
@adrai I've now included support for both mongodb like queries, as well as the firestore array syntax. @nanov I've updated the documentation as well, and (I think) got all of the ES6 out of there.
Regarding tests - what's the best way to set these up? Firestore is hosted by google, so credentials will be needed to get tests to hit the real implementation.
Actually, I think I've got this. I'll change the .travis.yml file to write out an environment variable with the credentials in it to a file, and use that for authentication with Google. I'll get those changes back here soon.
I've got all the tests passing now (bar the ones I've excluded with nested array support). I needed to add support for more functionality and concurrency checks - which is a good thing. I've also updated README.md with instructions on how to setup travis to work with the data store. Can you let me know if you feel anything is missing?
looks good... is there a reason why the tests are excluded?
Yes, it's because it would fail the tests if you merge to master, because the environment variable in your travis for the authentication with google won't be set up. I left the config for it commented out so you could add the authentication whenever you wanted, and wouldn't break existing tests.
Hi, i have no experience with firestore, and correct me if I'm wrong, but it seems like this is aimed at testing.
@nanov That's for testing cloud functions only - not the datastore itself. It simulates triggering the cloud functions once data in inserted/updated/deleted.
I might be able to use https://www.npmjs.com/package/mock-cloud-firestore to mock out the datastore if you like.
Hmm, as said, i have zero experience with Google Firebase Firestore so I cannot really tell, what other options there are to achieve automated testing? Maybe setting up a dedicated test account by google for this library?
EDIT: Are those things usually done with this mock library?
I had a look at that mocking library and it doesn't appear to support the features required for the concurrency checks. I think the only way to get automated testing is via setting up a dedicated account. But the owner of the project should probably own the account. I'm happy to set it up, and then transfer ownership to someone else.
Ok... then you are the owner of the project (at least for this db implementation) ;-)
Sorry for the long gap in communications - what's the best way to get the Firebase credentials to you? They shouldn't be exposed publicly.
perhaps if i give you access to the repo, you can encrypt the credentials directly for travis? So they are never exposed. Never tried this...
Hi, yes I can. That's no problem. Just need to paste in 1 variable in the config in travis, then uncomment the tests and it should just work. Let me know when access is granted, and I'll get it set up.
invited ;-)
Thanks for that. I've just had a look at travis and I can't see the project in my repositories list yet. Hopefully it'll appear after a sync or something.