Comments (9)
Thank you very much!
I reviewed the commit and LGTM. In the next days I will try it.
from gstore-node.
Hi,
What is the use case of having several instances? Is it just to have different namespace? In that case all the methods accept a namespace argument that should allow switching namespace anytime.
const namespace = require('./config').namespace1; // for example
Model.get(123, null, namespace).then( ... );
Would that not work for you?
from gstore-node.
That should work, however 1) It seems unnecessary to pass the namespace when you already told '@google-cloud/datastore'
what your namespace is 2) It is inconsistent behavior since you don't really have to pass the namespace unless you get in this situation so prone to bugs.
from gstore-node.
Ok I understand you have several datastore instances running. I never had this situation as I only configure the datastore once when my server start.
By curiosity, what is your use case ? As for me the purpose of the namespace is mainly to differentiate the environments of the app. Another use case would be to have one namespace by "business client", then as it is dynamic, you can not create "instances" of datastore ahead... So I am curious :)
from gstore-node.
I have multiple namespaces to help isolate different sources/types of data. Each datastore instance is associated with a given namespace and was hoping I could use gstore-node instance per datastore client per namespace so rest of the code I have doesn't need to pass in the namespaces to interact with datastore and simply operates on a specific gstore instance.
Your suggestion above to pass in namespace works but I think having a global or a singleton instance of gstore-node
when it is in fact wrapping a unique datastore instance is limiting. Not a big deal as I could work around it (thanks for your suggestion!)
from gstore-node.
I see. I will have a look into it. For now it needs to be singleton to ensure that Models are defined only once. That's why you can do this anywhere to retrieve a Model:
const gstore = require('gstore-node');
const MyModel = gstore.model('MyModel');
Having several instances would mean to store the Models differently.
from gstore-node.
I did the same workaround, I'm passing in namespace parameter for some call.
I have another use case for namespaces: I have a legacy datastore schema and I'm migrating to a new schema. I've decided to separate the different versions with namespaces, v1, v1.1, v2 etc so we can use the old and new one at the same time without interference.
IMO this enhancement would help to write data migration code easier for our use case.
from gstore-node.
Thanks for the feedback. I will look into a solution for this.
from gstore-node.
Hi,
I just released v2.0.0 that support multiple instances of gstore. I still have to update the docs but you can see how to do it in the release notes.
Let me know if there is any issue. thanks!
from gstore-node.
Related Issues (20)
- query filter on nested property value. HOT 5
- tsc error: Could not find a declaration file for module 'nsql-cache' HOT 3
- could not get data filter by entity key
- Support for @google-cloud/datastore version 5 HOT 2
- Support for custom validators (AJV)
- bulk insert? HOT 2
- Cannot read property 'Symbol(KEY)' when body is null or undefined HOT 1
- Typescript Compile Error HOT 2
- Support for HABTM
- Could not find gstore instance with id "${id}" HOT 2
- How to validate a value agains another property? HOT 1
- Datastore Key type error when using cache HOT 7
- Update method doesn't clear cache HOT 6
- Add Transaction support to `findOne` option HOT 1
- Support filtering for a missing optional property. HOT 1
- New query operators HOT 1
- @google-cloud/datastore version 7 support HOT 1
- could not get data filter by entity key HOT 1
- Migrate Travis CI builds to Circle CI
- Gstore node 7.2.8 TypeError: OptionalDataloader is not a constructor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gstore-node.