You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/cli/snapshots/integration/generators/relation.has-many-through.integration.snapshots.js
+200Lines changed: 200 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -701,3 +701,203 @@ export class DoctorRepository extends DefaultCrudRepository<
701
701
}
702
702
703
703
`;
704
+
705
+
706
+
exports[`lb4 relation HasManyThrough generates model relation with same table answers {"relationType":"hasManyThrough","sourceModel":"User","destinationModel":"User","throughModel":"Friend"} controller file has been created with hasManyThrough relation with same table 1`]=`
exports[`lb4 relation HasManyThrough generates model relation with same table answers {"relationType":"hasManyThrough","sourceModel":"User","destinationModel":"User","throughModel":"Friend"} has correct default foreign keys 1`]=`
821
+
import {Entity, model, property} from '@loopback/repository';
822
+
823
+
@model()
824
+
export class Friend extends Entity {
825
+
@property({
826
+
type: 'number',
827
+
id: true,
828
+
default: 0,
829
+
})
830
+
id?: number;
831
+
832
+
@property({
833
+
type: 'number',
834
+
})
835
+
userId?: number;
836
+
837
+
@property({
838
+
type: 'number',
839
+
})
840
+
friendId?: number;
841
+
842
+
constructor(data?: Partial<Friend>) {
843
+
super(data);
844
+
}
845
+
}
846
+
847
+
`;
848
+
849
+
850
+
exports[`lb4 relation HasManyThrough generates model relation with same table answers {"relationType":"hasManyThrough","sourceModel":"User","destinationModel":"User","throughModel":"Friend"} has correct imports and relation name users 1`]=`
851
+
import {Entity, model, property, hasMany} from '@loopback/repository';
exports[`lb4 relation HasManyThrough generates model relation with same table answers {"relationType":"hasManyThrough","sourceModel":"User","destinationModel":"User","throughModel":"Friend"} has correct imports and relation name users 2`]=`
880
+
import {inject, Getter} from '@loopback/core';
881
+
import {DefaultCrudRepository, repository, HasManyThroughRepositoryFactory} from '@loopback/repository';
882
+
import {DbDataSource} from '../datasources';
883
+
import {User, Friend} from '../models';
884
+
import {FriendRepository} from './friend.repository';
885
+
886
+
export class UserRepository extends DefaultCrudRepository<
887
+
User,
888
+
typeof User.prototype.id
889
+
> {
890
+
891
+
public readonly users: HasManyThroughRepositoryFactory<User, typeof User.prototype.id,
0 commit comments