Created
December 14, 2020 02:31
-
-
Save eduardopc/a2b44b752ba62de79db69aa73945ccb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BaseService } from "../../base"; | |
import { Animal, AnimalModel } from "../entities/animals"; | |
export class AnimalService extends BaseService<Animal> { | |
constructor() { | |
super(); | |
this.model = AnimalModel; | |
} | |
async findAllAnimalsAndPickOne() { | |
const animals = await this.model.find({}); | |
const idx = Math.floor(Math.random() * animals.length); | |
return animals[idx]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment