Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update method,support where query. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hustfyb
Copy link

@hustfyb hustfyb commented Mar 27, 2014

No description provided.

updateData=filter.update;
this.all(model, filter, function(err,records){
if (err) return callback(err);
for (var i=0;i<records.length;i++){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use forEach

@1602
Copy link
Contributor

1602 commented Mar 27, 2014

And couple more questions: what if one of updates failed? how to handle error?

@hustfyb
Copy link
Author

hustfyb commented Apr 2, 2014

I know the questions.To fix it should use event but it will import mass code. And I found another issue.
Part code

schema.models.push.create({pushId:"111111111111111111"},function(err,user){
    console.log(user);
    schema.models.push.all({},function(err,data){
        console.log(data);
    })
})

The all function will return 111111111111111100 not 111111111111111111.
It seems redis client change String to Number automaticly. I had checked redis, it's right.
Do you know the reason

@anatoliychakkaev
Copy link

How did you checked redis? For me it works as expected:

redis 127.0.0.1:6379> hmget a a

  1. (nil)
    redis 127.0.0.1:6379> hmset a 111111111111111111
    (error) ERR wrong number of arguments for 'hmset' command
    redis 127.0.0.1:6379> hmset a a 111111111111111111
    OK
    redis 127.0.0.1:6379> hmget a a
  2. "111111111111111111"
    redis 127.0.0.1:6379> hgetall a
  3. "a"
  4. "111111111111111111"

On 2 April 2014 08:13, hustfyb [email protected] wrote:

I know the questions.To fix it should use event but it will import mass
code. And I found another issue.
Part code

schema.models.push.create({pushId:"111111111111111111"},function(err,user){
console.log(user);
schema.models.push.all({},function(err,data){
console.log(data);
})})

The all function will return 111111111111111100 not 111111111111111111.
It seems redis client change String to Number automaticly. I had checked
redis, it's right.
Do you know the reason

Reply to this email directly or view it on GitHubhttps://github.com//pull/9#issuecomment-39295113
.

@hustfyb
Copy link
Author

hustfyb commented Apr 2, 2014

I found the reason. In BridgeToRedis.prototype.fromDb function you will convert string type to JSON object. That will change a number string to a real number, than js will lose precision. You should not touch the string type.

1 similar comment
@hustfyb
Copy link
Author

hustfyb commented Apr 2, 2014

I found the reason. In BridgeToRedis.prototype.fromDb function you will convert string type to JSON object. That will change a number string to a real number, than js will lose precision. You should not touch the string type.

@hustfyb
Copy link
Author

hustfyb commented Apr 2, 2014

Apologize for my pool English.

@hustfyb
Copy link
Author

hustfyb commented Apr 2, 2014

My error. I don't know when I delele some code, I didn't notice that, Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants