fixed search pagination (ObjectID deprecation)
This commit is contained in:
parent
69da49f2b3
commit
6f03bf49c5
@ -8,7 +8,7 @@ const { regions } = require('../data_providers/constants');
|
|||||||
const RsaProvider = require('../data_providers/rsa');
|
const RsaProvider = require('../data_providers/rsa');
|
||||||
const NomerogramProvider = require('../data_providers/nomerogram');
|
const NomerogramProvider = require('../data_providers/nomerogram');
|
||||||
const Utils = require('../utils/utils');
|
const Utils = require('../utils/utils');
|
||||||
const ObjectId = require('mongodb').ObjectID;
|
const ObjectId = require('mongodb').ObjectId;
|
||||||
const DebugInfo = require('../models/DebugInfo');
|
const DebugInfo = require('../models/DebugInfo');
|
||||||
const Vehicle = require('../models/vehicle');
|
const Vehicle = require('../models/vehicle');
|
||||||
|
|
||||||
@ -156,12 +156,12 @@ router.get('/', async (req, res) => {
|
|||||||
response.count = await collection.countDocuments(finalQuery);
|
response.count = await collection.countDocuments(finalQuery);
|
||||||
} else {
|
} else {
|
||||||
let compareOperator = isAscending ? '$gt' : '$lt';
|
let compareOperator = isAscending ? '$gt' : '$lt';
|
||||||
let lastVehicle = await collection.findOne({ _id: ObjectId(pageToken) });
|
let lastVehicle = await collection.findOne({ _id: new ObjectId(pageToken) });
|
||||||
finalQuery.$or = [
|
finalQuery.$or = [
|
||||||
{ [sortBy]: { [compareOperator]: lastVehicle[sortBy] } },
|
{ [sortBy]: { [compareOperator]: lastVehicle[sortBy] } },
|
||||||
{
|
{
|
||||||
[sortBy]: lastVehicle[sortBy],
|
[sortBy]: lastVehicle[sortBy],
|
||||||
_id: { [compareOperator]: ObjectId(pageToken) }
|
_id: { [compareOperator]: new ObjectId(pageToken) }
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user