import * as S from '@effect/schema/Schema'
import { BaseModel, ObjectId } from '@devx/core-domain'
export const getPaginatedResponse = <T>(schema: S.Schema<T>) =>
S.Struct({
data: S.Array(schema),
cursor: S.String,
hasMore: S.Boolean,
})
export const UserId = S.String.pipe(S.fromBrand(ObjectId))
export type UserId = S.Schema.Type<typeof UserId>
export class User extends S.Class<User>('User')({
...BaseModel.fields,
id: UserId,
username: S.optional(S.String),
}) {
static readonly _tag = 'User'
static readonly pluralName = 'Users'
}
getPaginatedResponse(User)
import * as S from '@effect/schema/Schema'
import { BaseModel, ObjectId } from '@devx/core-domain'
export const getPaginatedResponse = <T>(schema: S.Schema<T>) =>
S.Struct({
data: S.Array(schema),
cursor: S.String,
hasMore: S.Boolean,
})
export const UserId = S.String.pipe(S.fromBrand(ObjectId))
export type UserId = S.Schema.Type<typeof UserId>
export class User extends S.Class<User>('User')({
...BaseModel.fields,
id: UserId,
username: S.optional(S.String),
}) {
static readonly _tag = 'User'
static readonly pluralName = 'Users'
}
getPaginatedResponse(User)