Updating row search bookmark to handle numbers as bookmarks.

This commit is contained in:
mike12345567 2022-03-09 10:12:26 +00:00
parent a3a6aeb777
commit 53386909ab
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import { default as rowController } from "../row"
import { addRev } from "./utils"
import { Row } from "../../../definitions/common"
import { convertBookmark } from "../../../utilities"
// makes sure that the user doesn't need to pass in the type, tableId or _id params for
// the call to be correct
@ -30,7 +31,7 @@ export async function search(ctx: any, next: any) {
sort: sort.column,
sortType: sort.type,
sortOrder: sort.order,
bookmark,
bookmark: convertBookmark(bookmark),
paginate,
limit,
query,

View File

@ -151,3 +151,11 @@ exports.formatBytes = bytes => {
}
return `${size.toFixed(size < 10 && unit > 0 ? 1 : 0)}${units[unit]}`
}
exports.convertBookmark = bookmark => {
const IS_NUMBER = /^\d+\.?\d*$/
if (typeof bookmark === "string" && bookmark.match(IS_NUMBER)) {
return parseFloat(bookmark)
}
return bookmark
}