Estoy tratando de obtener una lista de mi mongodb al pasar una condición, pero cada vez que imprimo mi condición, no estoy definida.
async list(query: PaginationQuery): Promise<any> { const page = Number(query.page) - 1 || 0; let limit = Number(query.limit) || 20; const offset = page * limit; const sort = query.sort || 'createdAt'; const archived = this.convertArchived(query.archived); const conditions = { ...query.conditions, ...(!archived ? { deletedAt: undefined } : { deletedAt: { $ne: undefined } }) }; console.log(`HELP MEEE xx ${JSON.stringify(query.conditions)}`) const data = await this.model .find(conditions) .select(query.projections) .skip(offset) .limit(limit) .sort(sort); const totalDocuments = await this.model.countDocuments(conditions); const pageCount = Math.ceil(totalDocuments / limit); const pagination = { page: page + 1, limit, sortedBy: sort, pageCount }; return { data, pagination }; }este es mi repositorio
public async listAll() { const conditions = { role: 'surf' }; const data = { condition: conditions, page: 1, limit: 10 }; const all = await this.list(data); return all }Esto no tiene en cuenta la condición y solo devuelve todos los usuarios.
Mi interfaz de consulta de paginación se ve así
export interface PaginationQuery { archived?: boolean | string; conditions?: any; page?: number; limit?: number; projections?: any; sort?: string | object; }