Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

helper.ts

18 lines381 Bytes

1const RESERVED_RXDB_FIELDS = new Set([
2 `_rev`,
3 `_deleted`,
4 `_attachments`,
5 `_meta`,
6])
7​
8export function stripRxdbFields<T extends Record<string, any>>(
9 obj: T | any
10): T {
11 if (!obj) return obj
12 const out: any = Array.isArray(obj) ? [] : {}
13 for (const k of Object.keys(obj)) {
14 if (RESERVED_RXDB_FIELDS.has(k)) continue
15 out[k] = obj[k]
16 }
17 return out as T