--
You received this message because you are subscribed to the Google Groups "meteor-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-core...@googlegroups.com.
To post to this group, send email to meteo...@googlegroups.com.
Visit this group at http://groups.google.com/group/meteor-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Tom,Can you give an example of passing in a constructor? Also, the only reason I monkey-patched Collection was to limit the extension of the API. Essentially, this solution only adds to the API in two places: passing in the defaults object, and the collection.create method. I hate the monkey-patch, which is why I would rather have this functionality built-in.
Essentially, I don't think this solves the model support, or at least what people from the MVC, MVVM, MVP, etc. world consider a model. What this solves is the ability to define behavior to objects in a collection.If someone really wanted a model, they could use Backbone, and instantiate a Backbone.Model by passing in the object returned from a Meteor.Collection's find or findOne.While I'm not against the idea of having an actual model, where you can do model.save(), model.destroy(), etc., this adds to the API simply by duplicating functionality that is already provided.
I've attempted to wrap Backbone.js around Meteor, and failed. I think the architectural approaches are too different to make it worthwhile. I don't think the MVC or MVVC approach fits appropriately with Meteor. Possibly, the MVP will work (which is what I have been attempting), but either way, maybe Meteor is best left at being functional. But the lack of encapsulation reminds me of C. It's a dilema I'm having :)
This means that attributes of documents can have prototypes right? Although that's a lot better than nothing, it doesn't hit the most obvious use case, which is doing things like:var dog = Dogs.findOne(id);dog.name = "Max";dog.save();Or have I read the code wrong?
Also, have you considered that doing things like this (allowing deserialization to arbitrary classes) is the attack vector of multiple recent Rails (and Django?) security vulnerabilities. Not saying it's an inherently bad idea, just that it does increase the security surface area.
--
###Defines a user of the system.###class UserSchema extends APP.core.Schemaconstructor: (fields...) -> super fields,services: undefined # Services field that gets created by the Meteor frameworkname: # Name object.field: 'profile.name'modelRef: -> ns.Nameemail:field: 'profile.email'roleRefs: # Collection of ID references to roles the user is withinfield: 'profile.roleRefs'
###Represents a user of the system.###class User extends APP.core.DocumentModelconstructor: (doc) ->super doc, UserSchema, meteor.users
My only immediate suggestion would be to consider making an interface for an Association and a couple concrete classes for BelongsTo, HasOne, HasMany, etc. Then your Model or DocumentModel can delegate association calls to the Association interface.
--
You received this message because you are subscribed to a topic in the Google Groups "meteor-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meteor-core/hsJB9Y5JeLQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to meteor-core...@googlegroups.com.
To post to this group, send email to meteo...@googlegroups.com.
Visit this group at http://groups.google.com/group/meteor-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
I suspect people want to do both kinds of things, but I want to make sure they're not confused between their options.
--
You received this message because you are subscribed to the Google Groups "meteor-core" group.To unsubscribe from this group and stop receiving emails from it, send an email to meteor-core...@googlegroups.com.
To post to this group, send email to meteo...@googlegroups.com.
Visit this group at http://groups.google.com/group/meteor-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
Naomi, maybe templating/deftemplate.js could check If the cursor passed to #each has a factory, and if so apply the factory method to the items before sticking them in the data contexts? That way it could still keep the observeChanges call, and I don't think it would require changes to any other piece of code you're working on.
--
You received this message because you are subscribed to the Google Groups "meteor-core" group.To unsubscribe from this group and stop receiving emails from it, send an email to meteor-core...@googlegroups.com.
To post to this group, send email to meteo...@googlegroups.com.
Visit this group at http://groups.google.com/group/meteor-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Naomi,I've run into a couple of things in semi-implementing this (which I've done a couple of times[1], looking forward to the real thing!).1. Be careful making assumptions about the structure of documents that come out of the factory (or be very clear about what they need to look like).- I pointed out how EJSON.clone didn't quite work properly when documents had prototypes
- Likewise, Spark's apply changes function is fine for simple documents, but maybe you should let objects do it in their own way if they want to:if (_.isFunction(doc.applyChanges)) {doc.applyChanges(changeFields).} else {// ..copy attributes over}
In short, Spark does need to deal with modelled documents (so it can set them as data contexts for {{#each}} amongst other things).
2. There are some points where meteor internally calls observe + friends. Specifically I am thinking of mongo-livedata. I've run into lots of problems because livedata expects to just transfer the properties of what comes out of observe() over DDP, and throw them directly in minimongo at the other end.
c) very clearly specify what the structure of modelled documents needs to be.
There the main bugbears I've run into. If I were you I'd also take a look at my PR for a couple of tests that might still prove useful to you.
--