Effect.tryPromise({
try: async () => {
if (this.user.shortLinks) {
return this.user.shortLinks
}
await this.user.loadOnce('shortLinks')
if (this.user.shortLinks) {
return this.user.shortLinks
}
},
catch: LucidModelRelationshipError.fromUnknownError(User.name, ShortLink.name, 'shortLinks'),
}).pipe(
Effect.flatMap(_ => Effect.gen(function* () {
if (is.nullOrUndefined(_)) {
return yield* new LucidModelRelationshipError({ model: User.name, relationship: 'shortLinks', relatedModel: ShortLink.name })
}
return _
})),
)
Effect.tryPromise({
try: async () => {
if (this.user.shortLinks) {
return this.user.shortLinks
}
await this.user.loadOnce('shortLinks')
if (this.user.shortLinks) {
return this.user.shortLinks
}
},
catch: LucidModelRelationshipError.fromUnknownError(User.name, ShortLink.name, 'shortLinks'),
}).pipe(
Effect.flatMap(_ => Effect.gen(function* () {
if (is.nullOrUndefined(_)) {
return yield* new LucidModelRelationshipError({ model: User.name, relationship: 'shortLinks', relatedModel: ShortLink.name })
}
return _
})),
)