Closed cristyansv closed 6 years ago
Hi, Thanks for reporting this! I will have a look as soon as I can. Meanwhile can you try replacing line 154 by
if (resultCached === null || typeof resultCached === 'undefined') {
and let me know if it fixes the issue? thanks :+1:
after making this change, i get the following error:
(node:59646) UnhandledPromiseRejectionWarning: Error: Entity Key must be an instance of gcloud Key
at new Entity (/Users/cristyansepulveda/liveprojectbackend/node_modules/gstore-node/lib/entity.js:24:23)
at new Model (/Users/cristyansepulveda/liveprojectbackend/node_modules/gstore-node/lib/model.js:39:1)
at new ModelInstance (/Users/cristyansepulveda/liveprojectbackend/node_modules/gstore-node/lib/model.js:41:31)
at Function.__model (/Users/cristyansepulveda/liveprojectbackend/node_modules/gstore-node/lib/model.js:878:16)
at onSuccess (/Users/cristyansepulveda/liveprojectbackend/node_modules/gstore-node/lib/query.js:158:34)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
error is here:
function onSuccess(queryData) {
const { entities } = queryData;
if (entities.length === 0) {
return cb(new GstoreError(
errorCodes.ERR_ENTITY_NOT_FOUND,
`${Model.entityKind} not found`
));
}
const [e] = entities;
const entity = Model.__model(e, null, null, null, e[Model.gstore.ds.KEY]);
return cb(null, entity);
}
the javascript object seems not to be converted to the Model
Ok thanks for the feedback I will look into it asap 👍
I'm trying to use this for a project, but I haven't been able to get good results.
many times I update an Entity in one method, but when I call it from another method it brings me a previous version saved in cache.
The only solution I've had is to override the cache on every edition I make.
also the data behaves a little weird, for example if an entity has an id, in some cases it returns the id as a string, and but when it brings the entity from the cache it returns the id as an integer
I'd like to help solve these mistakes, but I'm a little lost where to start.
Hello, I started looking into the issue, I haven't found exactly the way to reproduce your first issue ("Cannot read property '0' of null") but I saw a bug elsewhere that might have an impact. I still have to make more trials.
You mentioned a few other issues (getting a cached version after an update instead of the latest version & getting a number id instead of a string).
The best would be to have a very small scenario where to reproduce those bugs and see from there. We then need to:
entity.save()...
)Model.update()...
)Model.get()
) and check that it returns the updated dataThis is what I usually do in a test file. If you can try to create a very small node project (1 file) with just this minimum this would be a great point to start.
Note that by default gstore will convert a string id of numbers ("1234"
) to a number (1234
). If you provide such IDs, then you have to set the Schema option keyType
to "name" (https://sebelga.gitbooks.io/gstore-node/content/schema/schema-options.html)
Cheers! :+1:
thank you!
right now I'm using the cache version in memory, because I can't get Redis to work.
I will try to make some small examples to better diagnose the problem
Hi @cristyansv I released a fix for the issue, v1.1.2. Could you try and let me know if it works?
Could you open a new issue for your other problem: "many times I update an Entity in one method, but when I call it from another method it brings me a previous version saved in cache". ? If you could add a simple scenario to reproduce it would help, thanks! :+1:
Hello, Did you have the chance to test the latest release with Redis client? cheers
I was having this issue and can confirm that the latest release fixed it for me 🎊
Great, thanks for the feedback!
When I try to make a basic query I get the following error
config:
Query:
global.db.UserModel.findOne({email}, null, null, {readAll: true});
erorr:
i think the error is here:
line 196: [unMarshalKeys(resultCached[0]), resultCached[1]]
https://github.com/sebelga/nsql-cache/blob/154b3324f0585733bf84d089d993764f0a1986b8/lib/queries.js#L153-L197