Comments (7)
Ok, been experimenting a bit. So far I've come up with this:
return entities.map((entity) => { delete entity.id; return new MyModelClass(entity, entity[gstore.KEY]); });
The delete entity.id seems needed as the query result includes this value, whereas the schema doesn't define this as a valid property. I am seeing some weird behaviour though, where saving the returned entity seems to result in new entities being added, instead of the existing one being updated.
from gstore-node.
That might be something nice to add as an option parameter to query.
Until then you guessed right that you need to delete the id first. Then, try something like this in your map (untested):
return entities.map((entity) => {
delete entity.id;
return MyModelClass.__model(entity, null, null, null, entity[gstore.KEY]);
});
Tell me if it worked.
from gstore-node.
Doesn't seem to give the desired effect. When debugging, in model.js:717, var entity is constructed. In the first case (i.e. after construction of the initial object), this.entityKey contains four fields:
- kind: User
- namespace: undefined
- path: undefined
- name : "[some uuid generated string]"
After executing a query, I call save again on the object constructed in the way described above. When I reenter model.js:717, this.entityKey does not have the name property.
from gstore-node.
Been debugging this on the fork I created, have the feeling the fromDatastore() function in datastore.js somehow does not copy the key.
from gstore-node.
Sorry I made a mistake. Inside the map function, its gstore.ds.KEY
to access the Symbol for the entityKey. So try with:
return entities.map((entity) => {
delete entity.id;
return MyModelClass.__model(entity, null, null, null, entity[gstore.ds.KEY]);
});
It should work.
from gstore-node.
Did you have a chance to try the solution?
from gstore-node.
Yes. It worked. After I finished with the virtual properties pull request, I'll craft up a feature to have this in the library itself.
Verstuurd vanaf mijn iPhone
Op 8 nov. 2016 om 18:20 heeft Sébastien Loix [email protected] het volgende geschreven:
Did you have a chance to try the solution?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
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.