import type { ICustomSound, RocketChatRecordDeleted } from '@rocket.chat/core-typings'; import type { ICustomSoundsModel } from '@rocket.chat/model-typings'; import type { Collection, FindCursor, Db, FindOptions, IndexDescription, InsertOneResult, UpdateResult, WithId } from 'mongodb'; import { BaseRaw } from './BaseRaw'; export class CustomSoundsRaw extends BaseRaw implements ICustomSoundsModel { constructor(db: Db, trash?: Collection>) { super(db, 'custom_sounds', trash); } protected modelIndexes(): IndexDescription[] { return [{ key: { name: 1 } }]; } // find findByName(name: string, options?: FindOptions): FindCursor { const query = { name, }; return this.find(query, options); } findByNameExceptId(name: string, except: string, options?: FindOptions): FindCursor { const query = { _id: { $nin: [except] }, name, }; return this.find(query, options); } // update setName(_id: string, name: string): Promise { const update = { $set: { name, }, }; return this.updateOne({ _id }, update); } // INSERT create(data: Omit): Promise>> { return this.insertOne(data); } }