Skip to content
6 changes: 4 additions & 2 deletions controllers/crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ const query = async function (req, res, next) {
}
const { limit, skip } = getPagination(req.query, { res })
try {
// One record past the page is read only to learn whether another page exists. It is never served.
let matches = await db.find(props).sort({ _id: 1 }).limit(limit + 1).skip(skip).toArray()
// Objects whose _id is not a string are bad data points, so they are not included.
// One record past the page is read only to learn whether another page exists.
let matches = await db.find({ $and: [props, { _id: { $type: "string" } }] })
.sort({ _id: 1 }).limit(limit + 1).skip(skip).toArray()
const hasNext = matches.length > limit
matches = matches.slice(0, limit).map(o => idNegotiation(o))
res.set(utils.configureLDHeadersFor(matches))
Expand Down
Loading
Loading