Coder Social home page Coder Social logo

mass updates about realm-js HOT 10 CLOSED

realm avatar realm commented on July 30, 2024
mass updates

from realm-js.

Comments (10)

astigsen avatar astigsen commented on July 30, 2024

In the Swift API you can do it like this:

realm.objects(MyClass).filter("prop2='key'").setValue(14, forKey: "prop1")

from realm-js.

bleonard avatar bleonard commented on July 30, 2024

you guys are so fancy with your chaining!
I don't have the immediate need, but would do something like that in JS eventually.

from realm-js.

bleonard avatar bleonard commented on July 30, 2024

It feels pretty inefficient to be looping in javascript to set a bunch of rows. Our MySQL equivalent use case is UPDATE jobs SET state='inactive' WHERE id NOT IN(array)

from realm-js.

alazier avatar alazier commented on July 30, 2024

In the short term we plan to support more js array methods including foreach and map. This should allow you to update each item without having to explicitly loop through each item, although underneath the hood we will still have a loop at some level.

from realm-js.

astigsen avatar astigsen commented on July 30, 2024

Is there any reason that we can't just implement the setValue() method in js as well?

from realm-js.

alazier avatar alazier commented on July 30, 2024

We could but this concept may be foreign to most js developers. We implemented setValue() in swift as setting values by keyPath is built into cocoa and expected by cocoa developers. My understanding is that the analogous functionality in JS is forEach and map. Adding setValue() would should be lower priority that these expected methods and wouldn't gain much as we would still have to loop through all elements (although we could avoid creating JS accessors).

from realm-js.

bleonard avatar bleonard commented on July 30, 2024

But it's not foreign to people that have been using sqlite/coredata in iOS that are now switching to React / Realm. Most engineers would assume it's significantly slower to do the iteration. That could be a big deal depending on the scale and they might be willing to deviate from common JS practices.

from realm-js.

alazier avatar alazier commented on July 30, 2024

Fair point. This is a feature that power users may expect and becomes much more important with larger data sets.

from realm-js.

bleonard avatar bleonard commented on July 30, 2024

to be clear, our set is not big enough for this to be a blocker, but just trying to help your success.

from realm-js.

kneth avatar kneth commented on July 30, 2024

Realm JS 2.0.0 introduced Realm.Results.update().

from realm-js.

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.