Skip to content

Releases: avanchugov/modular-orm

0.3.5

02 Jul 05:10

Choose a tag to compare

Minor update

In this update we added logQueriesValues option to StartParams

If logQueriesValues is enabled, then ORM will send values of queries. E.x

[ ModularORM ] Executed query SELECT * FROM playground_table_one WHERE (id = ? OR id = ?) in 2ms. Values: 1,2
[ ModularORM ] Executed query SELECT * FROM playground_table_one in 1ms. No values

0.3.51

02 Jul 07:38

Choose a tag to compare

Documentation update

In this update we`ve updated README.md

0.3.4

18 Jun 11:44

Choose a tag to compare

Minor patch

In this update work has been carried out on optimizing relations and working with metadata.

The execution of a find query with 1000 many-to-many relations and a depth of 10 was accelerated by 50%, reaching a record 99 milliseconds

    const startTime = new Date()
    const results = await coursesRepository.find({ id: 1 }, { relations: [Students, Courses], depth: 10 });
    console.log(results)
    const endTime = new Date();
    console.log(`${endTime.getTime() - startTime.getTime()} ms`)
[
  Courses {
    id: 1,
    course: 'somename',
    students: [
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      [Students], [Students], [Students], [Students], [Students],
      ... 899 more items
    ]
  }
]
99 ms

0.3.3

14 Jun 16:41

Choose a tag to compare

Minor update where we changed the logic of Repository#clone

Added

TableFieldStrings

export type TableFieldStrings<T> = (keyof T)[]

Description of exception while creating the table

ModularORMException: Error when executing table ranks. Table didnt created: Error: Cannot add foreign key constraint

Changes

Improve Repository#clone logic

SQL before:

SELECT * FROM users WHERE users = "Alice"

INSERT INTO users (name, age) VALUES ("Boris"...)
...

SQL After

INSERT INTO users (name, age) SELECT "Boris", age FROM users WHERE name = "Alice"

0.3.0

26 May 11:11

Choose a tag to compare

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