Skip to content

Commit

Permalink
switch to sequelize orm
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamp-sf committed Mar 3, 2023
1 parent 5f5eeca commit 321791c
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 10 deletions.
Binary file added loopback4-sequelize-2.1.0-new.tgz
Binary file not shown.
149 changes: 145 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@loopback/rest-explorer": "^5.0.8",
"@loopback/service-proxy": "^5.0.8",
"loopback-connector-postgresql": "^5.5.2",
"loopback4-sequelize": "file:loopback4-sequelize-2.1.0-new.tgz",
"tslib": "^2.0.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
CountSchema,
Filter,
FilterExcludingWhere,
IsolationLevel,
repository,
Where,
} from '@loopback/repository';
Expand All @@ -18,6 +17,7 @@ import {
requestBody,
response,
} from '@loopback/rest';
import {Transaction} from 'loopback4-sequelize';
import {User} from '../models';
import {UserRepository} from '../repositories';

Expand All @@ -36,7 +36,7 @@ export class UserController {
// Begin a new transaction.
// It's also possible to call `userRepo.dataSource.beginTransaction` instead.
const tx = await this.userRepository.beginTransaction({
isolationLevel: IsolationLevel.SERIALIZABLE,
isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE,
});

try {
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/db.datasource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {juggler} from '@loopback/repository';
import {SequelizeDataSource} from 'loopback4-sequelize';

const config = {
name: 'db',
Expand All @@ -17,7 +17,7 @@ const config = {
// Learn more at https://loopback.io/doc/en/lb4/Life-cycle.html
@lifeCycleObserver('datasource')
export class DbDataSource
extends juggler.DataSource
extends SequelizeDataSource
implements LifeCycleObserver
{
static dataSourceName = 'db';
Expand Down
4 changes: 2 additions & 2 deletions src/repositories/user.repository.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {inject} from '@loopback/core';
import {DefaultTransactionalRepository} from '@loopback/repository';
import {SequelizeCrudRepository} from 'loopback4-sequelize';
import {DbDataSource} from '../datasources';
import {User, UserRelations} from '../models';

export class UserRepository extends DefaultTransactionalRepository<
export class UserRepository extends SequelizeCrudRepository<
User,
typeof User.prototype.id,
UserRelations
Expand Down

0 comments on commit 321791c

Please sign in to comment.