Skip to content

0.3.0

Choose a tag to compare

@avanchugov avanchugov released this 26 May 11:11
· 8 commits to main since this release

This update added many new features and touched upon important aspects of our ORM.

Added

JoinBuilder in QueryBuilder

const builder = new QueryBuilder()
    .setTable(SomeTable)
    .setType(QueryType.SELECT)
    .setSelect(new SelectBuilder().addAll())
    .setJoin(
        new JoinBuilder()
            .setType('LEFT')
            .setTable('some_table_two')
            .setAlias('someAlias')
            .setOn(new WhereBuilder())
    )

⚠️ Feature is in Beta. And unfortunately, it is not used in new relations.

Ability to write OR conditions directly in Repository using arrays

const someRepository = new Repository(Some);
// Selects all from some table where user name is John or user money is 3000
let some : Some[] = await someRepository.find({ name: ['John'], money: 3000 })
// Where user name is John or Alice
some = await someRepository.find({ name: ['John', 'Alice'] });
// Where user name is Artur or user money is 3000 and not banned
some = await someRepository.find({ name: ['Artur'], balance: 3000, isBanned: false })

⚠️ If you need complex queries with groups, then use QueryBuilder

SoftDelete supports

There is now a SoftDeleteColumn decorator and several methods in Repository that allow you to automate soft deletes.

class Test extends Module {
    @SoftDeleteColumn()
    public deletedAt!: Date | QueryIs;
}

New methods in Repository

findOrFail, findOneByAutoincrementKey, findByAutoincrementKey, clone, softFindOne, softFind, softDelete and more

Relations

We have added relations (ManyToOne, OneToMany and ManyToMany) similar to TypeORM. You can read detailed examples from the documentation or in the sources

And much more

More details about the update in CHANGELOG.md

Changes

@migration is deprecated - there is now a separate setting for migrations in Column

ModularORM#getInstance now is not GET - To get an instance of the main class, call getInstance like a normal method