Giter VIP home page Giter VIP logo

Comments (6)

flam312 avatar flam312 commented on June 23, 2024

@svlungade can you give some more details as to what is in the array you are passing to the updateAll function?

The update all function works for me when passing in the following array:

User.updateAll( [ {'id': 1}, {'id': 2}, {'id': 3}, {'id': 4}], { 'updated' : true}, callback);

from loopback-connector-cloudant.

svlungade avatar svlungade commented on June 23, 2024

TestDocument.updateAll( {id: "1234"}, {email:

"[email protected]"}, function(err, results) {
console.log ('result is',results);
return callback(err, results);
});

Where id is a primary key (_id) and the first json is the condition and second is the one to be updated

This is what we are trying to do

from loopback-connector-cloudant.

flam312 avatar flam312 commented on June 23, 2024

@svlungade what is the error you see if any when you try to call the above code? I'm not sure I understand where the TypeError k.match error is coming from.

from loopback-connector-cloudant.

svlungade avatar svlungade commented on June 23, 2024

@flam312 - Thank you for the quick replies :).
There are 2 issues, the first one is you can ignore for now ... type k.match one.

Second issue is ... when we are trying with the example given, we are getting blank results, nothing gets updated.

from loopback-connector-cloudant.

flam312 avatar flam312 commented on June 23, 2024

@svlungade
Odd, so if you print results they are blank? You should see something print out for results.
For example if the update is successful you should get the in the result the id that was updated and the revision id.

{
"id": "123",
"rev": "16-393d8b69b74af75b4b787d8ecaa76e11"
}

Or if the id does not exist then the results will return { count: 0}.
However, if you get a error then I would expect results to be blank. Do you get anything when printing err?

from loopback-connector-cloudant.

tonyffrench avatar tonyffrench commented on June 23, 2024

@svlungade

In your first example the where clause is invalid it must be an object, not an array. You should have received an error like so: { [Error: The where clause [{"id":1},{"id":2},{"id":3},{"id":4}] is not an object] statusCode: 400 } https://docs.strongloop.com/display/public/LB/Where+filter

In the second case, you should get a response say function(err, info) where info.count indicates the number of documents updated. This works fine for me. Given that your using numbers for your primary key its very likely a duplicate of #2, make sure your Cloudant version is {"couchdb":"Welcome","version":"1.0.2","cloudant_build":"2579"} or later.

from loopback-connector-cloudant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.