@peerbit/indexer-interface
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -25,2 +25,7 @@ import { IntegerValue } from "./id.js"; | ||
} | ||
export type SortLike = string | { | ||
key: string[] | string; | ||
direction?: SortDirection | "asc" | "desc"; | ||
}; | ||
export declare const toSort: (sort?: SortLike | SortLike[]) => Sort[]; | ||
export declare abstract class LogicalQuery extends Query { | ||
@@ -27,0 +32,0 @@ } |
@@ -88,2 +88,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
export { Sort }; | ||
export const toSort = (sort) => { | ||
if (!sort) { | ||
return []; | ||
} | ||
if (typeof sort === "string") { | ||
return [new Sort({ key: sort })]; | ||
} | ||
if (Array.isArray(sort)) { | ||
return sort.map((x) => { | ||
if (typeof x === "string") { | ||
return new Sort({ key: x }); | ||
} | ||
return new Sort({ key: x.key, direction: x.direction }); | ||
}); | ||
} | ||
return [new Sort({ key: sort.key, direction: sort.direction })]; | ||
}; | ||
let LogicalQuery = class LogicalQuery extends Query { | ||
@@ -90,0 +107,0 @@ }; |
{ | ||
"name": "@peerbit/indexer-interface", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Indexer store interface", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -83,2 +83,23 @@ import { deserialize, field, serialize, variant, vec } from "@dao-xyz/borsh"; | ||
export type SortLike = | ||
| string | ||
| { key: string[] | string; direction?: SortDirection | "asc" | "desc" }; | ||
export const toSort = (sort?: SortLike | SortLike[]): Sort[] => { | ||
if (!sort) { | ||
return []; | ||
} | ||
if (typeof sort === "string") { | ||
return [new Sort({ key: sort })]; | ||
} | ||
if (Array.isArray(sort)) { | ||
return sort.map((x) => { | ||
if (typeof x === "string") { | ||
return new Sort({ key: x }); | ||
} | ||
return new Sort({ key: x.key, direction: x.direction }); | ||
}); | ||
} | ||
return [new Sort({ key: sort.key, direction: sort.direction })]; | ||
}; | ||
@variant(1) | ||
@@ -85,0 +106,0 @@ export abstract class LogicalQuery extends Query {} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
84264
1844