@central-credit/engine
Version:
Engine to handle the Serasa requests
179 lines (169 loc) • 3.92 kB
text/typescript
import {
Count,
CountSchema,
Filter,
repository,
Where
} from '@loopback/repository'
import {
post,
param,
get,
getFilterSchemaFor,
getModelSchemaRef,
getWhereSchemaFor,
patch,
put,
del,
requestBody
} from '@loopback/rest'
import { Record } from '../models'
import { RecordRepository } from '../repositories'
export class RecordController {
constructor(
public recordRepository: RecordRepository
) {}
async create(
record: Omit<Record, 'id'>
): Promise<Record> {
return this.recordRepository.create(record)
}
async count(
.query.object('where', getWhereSchemaFor(Record))
where?: Where<Record>
): Promise<Count> {
return this.recordRepository.count(where)
}
async find(
.query.object('filter', getFilterSchemaFor(Record))
filter?: Filter<Record>
): Promise<Record[]> {
return this.recordRepository.find(filter)
}
async updateAll(
record: Record,
.query.object('where', getWhereSchemaFor(Record))
where?: Where<Record>
): Promise<Count> {
return this.recordRepository.updateAll(record, where)
}
async findById(
.path.string('id') id: string,
.query.object('filter', getFilterSchemaFor(Record))
filter?: Filter<Record>
): Promise<Record> {
return this.recordRepository.findById(id, filter)
}
async updateById(
.path.string('id') id: string,
record: Record
): Promise<void> {
await this.recordRepository.updateById(id, record)
}
async replaceById(
.path.string('id') id: string,
record: Record
): Promise<void> {
await this.recordRepository.replaceById(id, record)
}
async deleteById(.path.string('id') id: string): Promise<void> {
await this.recordRepository.deleteById(id)
}
}