import {Repository} from '@orion-js/services'
import {createCollection, typedId} from '@orion-js/mongodb'
import {schemaWithName, InferSchemaType} from '@orion-js/schema'
const UserSchema = schemaWithName('UserSchema', {
_id: {type: typedId('user')},
email: {type: String},
firstName: {type: String},
lastName: {type: String},
createdAt: {type: Date}
})
type UserType = InferSchemaType<typeof UserSchema>
@Repository()
export class UserRepository {
users = createCollection({
name: 'users',
schema: UserSchema,
indexes: [
{
keys: {email: 1},
options: {unique: true}
},
{
keys: {createdAt: -1}
},
{
keys: {firstName: 1, lastName: 1}
}
]
})
// Repository methods...
}