| 224 | return data ? { id, data: Buffer.from(data).toString("base64") } : null |
| 225 | }, |
| 226 | async readMapObject(documentId, mapName) { |
| 227 | const doc = await loadDoc(documentId) |
| 228 | if (!doc) return null |
| 229 | try { |
| 230 | const value = toPlain(doc.getMap(mapName)) |
| 231 | return isRecord(value) ? value : {} |
| 232 | } finally { |
| 233 | doc.destroy() |
| 234 | } |
| 235 | }, |
| 236 | async readOrderedArray<T extends Record<string, unknown>>(documentId: string, name: string): Promise<T[] | null> { |
| 237 | const doc = await loadDoc(documentId) |
| 238 | if (!doc) return null |