Updating row search bookmark to handle numbers as bookmarks.

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

View File

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

View File

@ -151,3 +151,11 @@ exports.formatBytes = bytes => {
} }
return `${size.toFixed(size < 10 && unit > 0 ? 1 : 0)}${units[unit]}` 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
}