XuqmGroup-RNSDK/src/shims/watermelondb.ts

68 行
1.6 KiB
TypeScript

export class Model {
static table = ''
async update(updater: (record: this) => void | Promise<void>): Promise<this> {
await updater(this)
return this
}
async destroyPermanently(): Promise<void> {
return
}
}
export class Database {
constructor(_config: { adapter: unknown; modelClasses: Array<new (...args: unknown[]) => unknown> }) {}
async write<T>(action: () => Promise<T>): Promise<T> {
return action()
}
get<T>(_tableName: string): any {
return {
query: (..._queryParts: unknown[]) => ({
fetch: async () => [] as T[],
extend: () => ({
fetch: async () => [] as T[],
observe: () => ({ subscribe: () => undefined }),
}),
observe: () => ({ subscribe: () => undefined }),
}),
create: async (_builder: (record: T) => void | Promise<void>) => ({} as T),
}
}
}
export const Q: any = {
where: () => undefined,
take: () => undefined,
skip: () => undefined,
sortBy: () => undefined,
oneOf: () => undefined,
like: () => undefined,
gte: () => undefined,
lte: () => undefined,
sanitizeLikeString: (value: string) => value,
desc: undefined,
}
export function appSchema(input: unknown): any {
return input
}
export function tableSchema(input: unknown): any {
return input
}
export function field(_name: string): any {
return () => undefined
}
export function date(_name: string): any {
return () => undefined
}
export default class SQLiteAdapter {
constructor(_config: { schema: unknown; dbName: string; jsi?: boolean; onSetUpError?: (err: unknown) => void }) {}
}