mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
Merge pull request #11352 from waratuman/master
Adding missing static methods to Bookshelf
This commit is contained in:
@@ -71,6 +71,12 @@ class Tag extends bookshelf.Model<Tag> {
|
||||
get tableName() { return 'tags'; }
|
||||
}
|
||||
|
||||
User.where<User>('id', 1).fetch({withRelated: ['posts.tags']}).then(function(user) {
|
||||
console.log(user.related('posts').toJSON());
|
||||
}).catch(function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
new User().where('id', 1).fetch({withRelated: ['posts.tags']})
|
||||
.then(user => {
|
||||
const posts = user.related<Post>('posts');
|
||||
|
||||
2
bookshelf/bookshelf.d.ts
vendored
2
bookshelf/bookshelf.d.ts
vendored
@@ -93,6 +93,8 @@ declare module 'bookshelf' {
|
||||
static fetchAll<T extends Model<any>>() : Promise<Collection<T>>;
|
||||
/** @deprecated should use `new` objects instead. */
|
||||
static forge<T>(attributes? : any, options? : ModelOptions) : T;
|
||||
static where<T>(properties: { [key: string]: any }): T;
|
||||
static where<T>(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | number | boolean): T;
|
||||
|
||||
belongsTo<R extends Model<any>>(target : {new(...args : any[]) : R}, foreignKey? : string) : R;
|
||||
belongsToMany<R extends Model<any>>(target : {new(...args : any[]) : R}, table? : string, foreignKey? : string, otherKey? : string) : Collection<R>;
|
||||
|
||||
Reference in New Issue
Block a user