Code Monkey home page Code Monkey logo

Comments (5)

aldeed avatar aldeed commented on May 18, 2024

I understand the use case. Virtual fields are inherently "a collection2 thing" since they rely on transform, but it's possible that we could rethink the options "API" such that they are defined in SS definitions (similar to how denyUpdate, etc. are inherently related to collections, but C2 has you define them in the schema definition object.

Specifically, I'm thinking of something like this:

var c = new Meteor.Collection("c", {
  schema: new SimpleSchema({
    creatorEmail: {
      type: String,
      virtual: function (doc) {
        return getCreatorEmail(doc.createdBy);
      }
    }
  });
});

This would require a way to tell the simple-schema package to ignore definitions that are virtual. I'm not sure I'm sold on doing it yet, but we can keep this open as a proposal.

from meteor-simple-schema.

serkandurusoy avatar serkandurusoy commented on May 18, 2024

You're right, it would also contextually make sense to keep it in c2.

As I am progressing on my first "rather complicated" meteor app (coming
from javaee), I see this multiple times. It may not always be the case
but for the current app, my schemas often share properties that can
otherwise be reused and be represented in other ways. Virtualfields
would have been a great fit for the use case. Currently, I'm trying to
pass those properties through some common utility functions after I
retrieve them. Trying to keep them reactive, though is the harder part
which seems to require even further abstraction. In the end, the code
becomes harder to follow and maintain.

On 01/16/2014 08:07 PM, Eric Dobbertin wrote:

I understand the use case. Virtual fields are inherently "a
collection2 thing" since they rely on transform, but it's possible
that we could rethink the options "API" such that they are defined in
SS definitions (similar to how |denyUpdate|, etc. are inherently
related to collections, but C2 has you define them in the schema
definition object.

Specifically, I'm thinking of something like this:

var c = new Meteor.Collection("c", {
schema: new SimpleSchema({
creatorEmail: {
type: String,
virtual: function (doc) {
return getCreatorEmail(doc.createdBy);
}
}
});
});

This would require a way to tell the simple-schema package to ignore
definitions that are virtual. I'm not sure I'm sold on doing it yet,
but we can keep this open as a proposal.


Reply to this email directly or view it on GitHub
#49 (comment).

from meteor-simple-schema.

serkandurusoy avatar serkandurusoy commented on May 18, 2024

Oh, now I get this. Brilliant!

On 01/16/2014 08:07 PM, Eric Dobbertin wrote:

I understand the use case. Virtual fields are inherently "a
collection2 thing" since they rely on transform, but it's possible
that we could rethink the options "API" such that they are defined in
SS definitions (similar to how |denyUpdate|, etc. are inherently
related to collections, but C2 has you define them in the schema
definition object.

Specifically, I'm thinking of something like this:

var c = new Meteor.Collection("c", {
schema: new SimpleSchema({
creatorEmail: {
type: String,
virtual: function (doc) {
return getCreatorEmail(doc.createdBy);
}
}
});
});

This would require a way to tell the simple-schema package to ignore
definitions that are virtual. I'm not sure I'm sold on doing it yet,
but we can keep this open as a proposal.


Reply to this email directly or view it on GitHub
#49 (comment).

from meteor-simple-schema.

aldeed avatar aldeed commented on May 18, 2024

@serkandurusoy, after checking out the code for the collection-helpers package, I'm thinking about deprecating virtual field support entirely and having people use that package instead. I think it's a better method. I also opened an issue for a collection-helpers enhancement which, if added, would I think meet your needs.

from meteor-simple-schema.

serkandurusoy avatar serkandurusoy commented on May 18, 2024

Sounds very logical and I'm sure everyone would benefit from the gains introduced by such decision.

from meteor-simple-schema.

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.