Relational method calls should be available on resource's constructor #110

Marak opened this Issue Aug 28, 2012 · 2 comments


None yet

3 participants

Marak commented Aug 28, 2012

It seems that the only way to call a relational method ( i.e., Resource.createChild, or Author.createArticle ), is on an instance of the parent resource.

Relational method calls should be available on both the constructor and the instance.

For example:

var resourceful = require('../lib/resourceful');
// First, create two resources: Author and Article
var Author = resourceful.define('author');

var Article = resourceful.define('article');

// Now we add a special property to Article indicating that Author is its parent

// Create a new article "good-article", written by "bob"

This works

Author.create({ id: 'bob'}, function(err, bob){
  console.log(err, bob)
  bob.createArticle({ id: 'good-article'}, function(err, article){
    console.log(err, article)

This does not

// console.log(Author.createArticle.toString())
  id: 'bob',
  article_id: 'good-article'
}, function(err, bob){
  console.log(err, bob)

Both of these api's should work

Judging from the Relational Resources docs this is solved right?

@Marak Marak closed this May 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment