We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to use Backbone-relational with typescript. My sample code looks like this :
`import * as Backbone from 'backbone'; import 'backbone-relational';
class Animal extends Backbone.RelationalModel{ constructor(options){ super(options); this.urlRoot = '/animal/'; }
}
Animal.setup();
class AnimalCollection extends Backbone.Collection{ constructor(any){ super(any); this.model = Animal; } }
class Zoo extends Backbone.RelationalModel{ constructor(options){ super(options); this.relations =[{ type: Backbone.HasMany, key: 'animals', relatedModel: 'Animal', collectionType: 'AnimalCollection', reverseRelation: { key: 'livesIn', includeInJSON: 'id' // 'relatedModel' is automatically set to 'Zoo'; the 'relationType' to 'HasOne'. } }]; }
Zoo.prototype.relations = [{ type: Backbone.HasMany, key: 'animals', relatedModel: 'Animal', collectionType: 'AnimalCollection', reverseRelation: { key: 'livesIn', includeInJSON: 'id' // 'relatedModel' is automatically set to 'Zoo'; the 'relationType' to 'HasOne'. } }];
Zoo.setup();
//let artis = Zoo.build({ name: 'Artis' });
let artis = new Zoo({ name: 'Artis' });
//let lion = Animal.build( { species: 'Lion', livesIn: artis } );
let lion = new Animal( { species: 'Lion', livesIn: artis } );
alert( artis.get( 'animals' ).pluck( 'species' ) ); // artis.get( 'animals' ) undefined`
Unfortunately above code doesn't work. the _relations of artis gives empty object and throws error
Relation=child: missing model, key or relatedModel (class Zoo extends Backbone.RelationalModel {
please help
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am trying to use Backbone-relational with typescript. My sample code looks like this :
`import * as Backbone from 'backbone';
import 'backbone-relational';
class Animal extends Backbone.RelationalModel{
constructor(options){
super(options);
this.urlRoot = '/animal/';
}
}
Animal.setup();
class AnimalCollection extends Backbone.Collection{
constructor(any){
super(any);
this.model = Animal;
}
}
class Zoo extends Backbone.RelationalModel{
constructor(options){
super(options);
this.relations =[{
type: Backbone.HasMany,
key: 'animals',
relatedModel: 'Animal',
collectionType: 'AnimalCollection',
reverseRelation: {
key: 'livesIn',
includeInJSON: 'id'
// 'relatedModel' is automatically set to 'Zoo'; the 'relationType' to 'HasOne'.
}
}];
}
}
Zoo.prototype.relations = [{
type: Backbone.HasMany,
key: 'animals',
relatedModel: 'Animal',
collectionType: 'AnimalCollection',
reverseRelation: {
key: 'livesIn',
includeInJSON: 'id'
// 'relatedModel' is automatically set to 'Zoo'; the 'relationType' to 'HasOne'.
}
}];
Zoo.setup();
//let artis = Zoo.build({ name: 'Artis' });
let artis = new Zoo({ name: 'Artis' });
//let lion = Animal.build( { species: 'Lion', livesIn: artis } );
let lion = new Animal( { species: 'Lion', livesIn: artis } );
alert( artis.get( 'animals' ).pluck( 'species' ) );
// artis.get( 'animals' ) undefined`
Unfortunately above code doesn't work. the _relations of artis gives empty object and throws error
Relation=child: missing model, key or relatedModel (class Zoo extends Backbone.RelationalModel {
please help
The text was updated successfully, but these errors were encountered: