FabricLabs / maki

:bento: declarative application framework for high-performance cross-platform services
https://maki.io
MIT License
69 stars 33 forks source link

Subresource Population Settings Ignored in Updates #119

Open martindale opened 8 years ago

martindale commented 8 years ago

When a Resource has a particular attribute configured to be "populated" for specific methods, these rules are not respected when the parent resource emits update events:

For example, from Melody:

var PostSchema = {
  content: { type: String },
  created: { type: Date , default: Date.now },
  _identity: { type: melody.mongoose.SchemaTypes.ObjectId , ref: 'Identity', required: true },
  _author: {
    type: melody.mongoose.SchemaTypes.ObjectId,
    ref: 'Person',
    populate: ['query', 'get']
  }
};

Perhaps handlers for the populate option should be expanded to include the update or patch methods.

martindale commented 8 years ago

Alternatively, if resources contain pointers to other resources, perhaps the UX layer should always be the one handling this. Thoughts, @chrisinajar?

chrisinajar commented 8 years ago

What does the populate gesture do? It's probably a Data Layer or maybe Application State responsibility...

martindale commented 8 years ago

The populate option indicates that, when a resource is retrieved in a specific context (query vs. get, for example), any references to other documents should be replaced with the actual documents themselves. It's a "hyperlink" to another, separate (but related) document.

I imagine that in the production deployment of Fabric, these will always be document hashes (the content-addressable part), but for now we are mainly using Mongo's ObjectIDs.