Skip to content

fabrix-app/spool-waterline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spool-waterline

Gitter NPM version Build Status Test Coverage Dependency Status Follow @FabrixApp on Twitter

Loads Application Models (in api/models) into the Waterline ORM; Integrates with spool-router to generate Tapestries for routes.

Usage

Configure

// config/main.ts
import { WaterlineSpool } from '@fabrix/spool-waterline'
export const main = {
  // ...
  spools: [
    // ...other spools
    WaterlineSpool
  ]
}

Query

// api/services/BirthdayService.ts
export class BirthdayService extends Service {
  /**
   * Finds people with the given birthday.
   * @return Promise
   * @example {
   *    name: 'Ludwig Beethoven',
   *    birthday: Sun Dec 16 1770 00:00:00 GMT-0500 (EST),
   *    favoriteColors: [
   *      { name: 'yellow', hex: 'ffff00' },
   *      { name: 'black', hex: '000000' }
   *     ]
   * }
   */
  findPeopleWithBirthday (birthday) {
    return this.orm.Person.find({ birthday: birthday })
      .populate('favoriteColors')
  }
}

Contributing

We love contributions! Please check out our Contributor's Guide for more information on how our projects are organized and how to get started.

License

MIT