File size: 444 Bytes
4327358
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { IJsonQuery } from '@waha/core/storage/sql/IJsonQuery';

export class Sqlite3JsonQuery implements IJsonQuery {
  filter(field: string, key: string, value: any): [string, string] {
    const jsonPath = `$.${key}`;
    return [`${field}->'${jsonPath}' = ?`, `${value}`];
  }

  sortBy(field: string, sortBy: string, direction: string): string {
    const jsonPath = `$.${sortBy}`;
    return `${field}->'${jsonPath}' ${direction}`;
  }
}