Me enfrento a un problema que no puedo resolver solo.
Tengo una colección MongoDB, en esta colección tengo 1 documento atm.
Cuando uso .findById(_id) o .findOne({_id : id}) con el _id correcto, todo funciona.
.findById(_id) .findOne({_id : id}) .
¡Ty por tu tiempo, cuídate!
EDITAR :
export interface OrderDocument extends mongoose.Document { user: UserDocument['_id']; asset_bought: AssetDocument['_id']; asset_b_symbol: string; asset_sold: AssetDocument['_id']; asset_s_symbol: string; exchange: ExchangeDocument['_id']; exchange_name: string; is_draft: Boolean; amount: number; atm_price: number; date: Date; } const orderSchema = new mongoose.Schema( { _id: { type: mongoose.Schema.Types.ObjectId }, user: { type: mongoose.Schema.Types.ObjectId, ref: 'users', required: true, }, asset_bought: { type: mongoose.Schema.Types.ObjectId, ref: 'assets', required: true, }, asset_b_symbol: { type: String, required: true, }, asset_sold: { type: mongoose.Schema.Types.ObjectId, ref: 'assets', required: true, }, asset_s_symbol: { type: String, required: true, }, exchange: { type: mongoose.Schema.Types.ObjectId, ref: 'exchanges', required: true, }, exchange_name: { type: String, required: true, }, is_draft: { type: Boolean, default: false }, amount: { type: Number, required: true }, atm_price: { type: Number, required: true }, date: { type: Date, required: true }, }, { timestamps: true } ); export async function findAndPopulateOrders( searchType: 'id' | 'one' | 'many', query: FilterQuery<OrderDocument>, _collections: Array<string> ) { const collections = _collections.join(' '); if (searchType === 'id') { return await OrderModel.findById(query).populate(collections); } else if (searchType === 'one') { return await OrderModel.findOne(query).populate(collections); } else if (searchType === 'many') { return await OrderModel.find(query).populate(collections); } else { return {}; } }