rapidjs / rapid.js

An ORM-like Interface and a Router For Your API Requests
https://rapidjs.drewjbartlett.com
710 stars 45 forks source link

add ability for children #16

Closed drewjbartlett closed 6 years ago

drewjbartlett commented 7 years ago

Say I have a User model and that user has Notifications. It'd be nice to either say this:

class User extends Rapid {
    boot () {
        this.notifications = new Rapid({ childOf: this });
    }
}

Or it'd be nice to:

let User = new Rapid({
    modelName: 'user',
    children: [{ modelName: 'notifications' }, { modelName: 'meta' }]
})

this would result in being able to do:

User.notifications.post('mark-as-read'); // => /api/user/notifications/mark-as-read