Closed hatemragab closed 1 year ago
Hello, thanks for your collab.
I don't understand the reason why the search doesn't works for you. As I wrote in the lib documentation, on rules topic:
Anything other than limit, skip, page, sort, select and populate will be considered a filter;
So if you type a query where the key is mT
and the value is _dsff
, the lib will consider this search as a filter, so in the field filter
you will get the filter as { mT: '_dsff' }
. You can use it for get some data in the database, using the prop filter
from the MongoQueryModel
. For example:
@Injectable()
export class MessageService {
constructor(
@InjectModel(Message.name)
private readonly _model: Model<MessageDocument>,
) {}
async find(query: MongoQueryModel) {
return this._model
.find(query.filter) // in this case, .find ({ mT: '_dsff' })
.limit(query.limit) // in this case, .limit(100)
.skip(query.skip) // in this case, .skip(0)
.sort(query.sort) // in this case, .sort({})
.select(query.select) // in this case, .select({})
.exec();
}
}
it generate