| 397 | }, |
| 398 | |
| 399 | create(type, data) { |
| 400 | const store = getStore(type); |
| 401 | const pkField = PK_FIELD[type]; |
| 402 | const pk = pkField !== undefined ? data[pkField] : JSON.stringify(data); |
| 403 | // Shallow-copy so later mutations to the caller's object don't affect |
| 404 | // what the store holds. Attach a non-enumerable tag for delete(). |
| 405 | const stored = Object.defineProperty({ ...data }, '_realmMeta', { |
| 406 | value: { type, pk }, |
| 407 | enumerable: false, |
| 408 | }); |
| 409 | store.set(pk, stored); |
| 410 | }, |
| 411 | |
| 412 | delete(target) { |
| 413 | if (!target) return; |