Repository navigation
Expand file tree
/
Copy pathcontext7.json
More file actions
49 lines (49 loc) · 5.5 KB
/
Copy pathcontext7.json
File metadata and controls
49 lines (49 loc) · 5.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
"$schema": "https://context7.com/schema/context7.json",
"projectTitle": "RxDB",
"description": "RxDB (Reactive Database) is a local-first, NoSQL database for JavaScript applications, with realtime replication. Runs in browsers, Node.js, React Native, Expo, Electron, and Capacitor.",
"folders": [
"docs-src/docs",
"examples"
],
"excludeFolders": [
"docs-src/docs/releases",
"examples/flutter",
"**/test",
"**/tests",
"**/e2e",
"**/node_modules",
"**/android",
"**/ios",
"**/dist",
"**/build"
],
"excludeFiles": [
"CHANGELOG.md",
"rx-storage-lokijs.md",
"rx-storage-pouchdb.md",
"adapters.md",
"flutter-database.md",
"ideas.md",
"generic-prompts.md",
"contribute.md"
],
"rules": [
"Install with `npm install rxdb rxjs`. Import core APIs from 'rxdb' (or 'rxdb/plugins/core'), plugins from 'rxdb/plugins/<name>', and premium plugins from 'rxdb-premium/plugins/<name>'.",
"In development, call `addRxPlugin(RxDBDevModePlugin)` (from 'rxdb/plugins/dev-mode') before creating a database, and wrap the storage with `wrappedValidateAjvStorage({ storage })` from 'rxdb/plugins/validate-ajv'. Do not ship dev-mode to production.",
"Create a database with `await createRxDatabase({ name, storage })` and collections with `await db.addCollections({ todos: { schema } })`. Old APIs like `RxDB.create()`, `db.collection()` and PouchDB adapters do not exist in current RxDB.",
"Every schema needs `version` (start at 0), `primaryKey`, `type: 'object'` and `properties`. The primary key field must be a string with `maxLength` set. When a schema changes, increase `version`, add `RxDBMigrationSchemaPlugin`, and provide a `migrationStrategies` function for each new version.",
"The open-source version allows 13 open collections in parallel (`NON_PREMIUM_COLLECTION_LIMIT`, error `COL23`). Premium users remove the limit by calling `setPremiumFlag()` from 'rxdb-premium/plugins/shared' before creating the first database. Prefer fewer collections with a `type` field over many small collections.",
"Pick the storage per platform. Browser: `getRxStorageLocalstorage()` (free, small data), `getRxStorageDexie()` (free), or premium `getRxStorageIndexedDB()` / OPFS (`getRxStorageOPFS()` inside a worker via `getRxStorageWorker()`, or `getRxStorageOPFSMainThread()`). Tests: `getRxStorageMemory()`.",
"React Native and Expo: use premium `getRxStorageSQLite()` from 'rxdb-premium/plugins/storage-sqlite' (with `getSQLiteBasicsExpoSQLiteAsync(SQLite.openDatabaseAsync)` or `getSQLiteBasicsQuickSQLite(open)`) or premium `getRxStorageExpoAsync()` from 'rxdb-premium/plugins/storage-filesystem-expo'. For free prototypes use `getRxStorageSQLiteTrial()` from 'rxdb/plugins/storage-sqlite' (max 500 documents, no indexes, not for production). Capacitor: SQLite storage with `getSQLiteBasicsCapacitor(sqlite, Capacitor)`.",
"Electron: run the storage (for example SQLite) in the main process and expose it with `exposeIpcMainRxStorage()`; in the renderer use `getRxStorageIpcRenderer()` from 'rxdb/plugins/electron'. Node.js: SQLite with `getSQLiteBasicsNodeNative(DatabaseSync)` from 'node:sqlite', or premium `getRxStorageFilesystemNode()`, or `getRxStorageMemory()`.",
"The LokiJS storage (removed in v16) and the PouchDB storage (removed in v14) no longer exist. Never import 'rxdb/plugins/storage-lokijs' or 'rxdb/plugins/storage-pouchdb'.",
"Query with MongoDB-style (Mango) selectors: `collection.find({ selector: { done: { $eq: false } }, sort: [{ createdAt: 'asc' }] })`. Call `.exec()` for a one-time result or subscribe to `.$` for a reactive result that updates on every change.",
"RxDocuments are immutable. Change data with `doc.incrementalPatch({...})` or `doc.incrementalModify(fn)` (or `patch()` / `modify()`), never by assigning fields. Delete with `doc.remove()`; deleted documents are kept with `_deleted: true` so the delete can replicate.",
"Replication: use `replicateRxCollection({ collection, replicationIdentifier, live: true, pull: { handler(lastCheckpoint, batchSize) }, push: { handler(rows) } })` from 'rxdb/plugins/replication'. The pull handler returns `{ documents, checkpoint }`. The push handler gets rows with `newDocumentState` and `assumedMasterState` and returns the conflicting master documents (empty array if none). Wait with `await replicationState.awaitInitialReplication()`.",
"`awaitInitialReplication()` resolves when both pull and push finished their first cycle. `pause()` + `start()` resumes the same replication state. `cancel()` is final: `start()` throws `RC_START_CANCELED` afterwards, so call `replicateRxCollection()` again with the same `replicationIdentifier` to continue from the stored checkpoint. `remove()` also deletes that checkpoint.",
"Prefer the ready-made replication plugins when a backend matches: `replicateCouchDB`, `replicateGraphQL`, `replicateSupabase`, `replicateFirestore`, `replicateMongoDB`, `replicateAppwrite`, `replicateNats`, `replicateWebRTC` (P2P), and the HTTP or WebSocket protocols. The backend must store the `_deleted` flag and a checkpoint field such as `updatedAt`.",
"React and React Native: wrap the app in `RxDatabaseProvider` and use `useRxCollection`, `useRxQuery` and `useLiveRxQuery` from 'rxdb/plugins/react'.",
"To delete a database without an instance, call `removeRxDatabase(name, storage, multiInstance, password)` with the same storage object (not a string). For encrypted databases pass the `wrappedKeyEncryptionCryptoJsStorage` storage and the password, otherwise it throws `EN3`."
]
}