Code Monkey home page Code Monkey logo

Comments (2)

craig-l avatar craig-l commented on May 21, 2024

Probably isn't feasible to observe just anything... maybe just tie autoValue in to relationships in issue #31 so it can recalculate every time a related object changes/inserts/deletes.. that would cover most use cases of autoValue when looking for a precalculated "virtual field."

from meteor-collection2.

aldeed avatar aldeed commented on May 21, 2024

I might not be thinking everything through, but it seems like there are a number of other ways this could be handled:

  1. sales could be a virtual field. The calculation would be done more often than necessary, but it would work.
  2. You could allow updating sales from the server only and then do a server-side observe on an Invoices.find() cursor, which would update customer.sales whenever invoice.total changes. (Haven't tried the specifics, but it seems like it would work. It's similar to what you're suggesting allowObserve should do.) A while ago I had the idea to add a serverOnly: true option to schemas, but there was never a great use case, but maybe something like this is one. You can do it manually in a deny function, though.

In general the idea of using autoValue to enforce a particular value based on another collection is something I haven't thought much about, but I feel like it's perhaps overkill since there is custom observe and other ways to accomplish it. Nevertheless, I can see where one might expect autoValue to be able to do that, so it's something to keep in mind.

You're correct also that it might tie in with relationships development eventually. Maybe some way of defining a related field as a "count" or "sum" field.

I'll have to think about this.id, too. Since I'm not yet convinced this is a good use of autoValue, I'm also not yet convinced that this.id is necessary.

from meteor-collection2.

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.