Updating row search bookmark to handle numbers as bookmarks.
This commit is contained in:
parent
a3a6aeb777
commit
53386909ab
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue