Thank you your contribution. I'm happy using this lib :)
I'm planning to use 0.5.0 rc version.
So, all the relations I can use are these, right?
OneToOne -> HasOneRelation,
OneToMany -> HasManyRelation,
OneToOne -> BelongsToOneRelation,
ManyToManyRelation,
Could you explain some other features about 0.5.0?
Or, when will you release next version(document) ?
I want to know other features about next version 馃槃
The old OneToOne is now BelongsToOne and there previously was no equivalent for the HasOne.
Other new features in 0.5.0:
joinRelation method. This is just a shortcut for joining a related table and giving the joined table an alias based on on the relation name. For example Person.query().joinRelation('children').where('children.age', '>', 10)
withSchema method now works as expected and passes the given schema to all executed queries.filterEager method. This is a better syntax for filtering eager expressions. Example:Person
.query()
.eager('[children.movies, pets]')
.filterEager('children.movies', builder => builder.where('releaseYear', '<', '1985')
.filterEager('pets', builder => builder.where('species', 'dog')
ManyToMany relations. You can select which properties of the model are inserted to the join table instead of the related table. Example:// In Person.js
...
relationMappings = {
movies: {
relation: Model.ManyToManyRelation,
modelClass: Movie,
join: {
from: 'Person.id',
through: {
from: 'Movie_Person.personId',
to: 'Movie_Person.movieId',
extra: ['type'] // <--- NOTE THIS LINE
},
to: 'Movie.id'
}
}
}
...
// Now this query inserts a new movie for a person and sets the `type`
// column of the created join row in the join table to value `Actor`
person
.$relatedQuery('movies')
.insert({firstName: 'Foo', lastName: 'Bar', type: 'Actor'})
// This fetches the movies with the `extra` properties joined.
let movies = person.$relatedQuery('movies')
console.log(movies[0].type)
person.parent.^3. That would only fetch three levels of ancestors for the person.The 0.5.0 version will be released soon. I'm currently just cleaning up the code and writing more tests. I won't write any new features for it.
By the way, you can always find the up-to-date documentation from the doc folder. That folder contains the markdown files that are used to generate the documentation website. They are pretty readable.
This info can now be found in the changelog. Closing.
Most helpful comment
The old
OneToOneis nowBelongsToOneand there previously was no equivalent for theHasOne.Other new features in 0.5.0:
joinRelationmethod. This is just a shortcut for joining a related table and giving the joined table an alias based on on the relation name. For examplewithSchemamethod now works as expected and passes the given schema to all executed queries.filterEagermethod. This is a better syntax for filtering eager expressions. Example:ManyToManyrelations. You can select which properties of the model are inserted to the join table instead of the related table. Example:person.parent.^3. That would only fetch three levels of ancestors for the person.The 0.5.0 version will be released soon. I'm currently just cleaning up the code and writing more tests. I won't write any new features for it.