{"id":470192,"date":"2025-08-10T21:00:05","date_gmt":"2025-08-10T21:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=470192"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=470192","title":{"rendered":"<span>React Native + RxDB: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c Local-First \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0441\u0434\u043e\u0445\u043d\u0435\u0442 \u0431\u0435\u0437 \u0441\u0432\u044f\u0437\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435: \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. \u041d\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430? \u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e, \u0443 \u0432\u0430\u0441 \u043c\u0451\u0440\u0442\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043a\u0443\u0447\u0430 \u043d\u0435\u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0443 \u0438\u043b\u0438 \u043a\u0443\u0440\u044c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u043e\u0438\u0442 \u043a\u0430\u043a \u0434\u0443\u0440\u0430\u043a \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u043b\u043e. \u0411\u0438\u0437\u043d\u0435\u0441 \u0441\u0442\u043e\u0438\u0442, \u0430 \u0432\u044b \u0441\u0438\u0434\u0438\u0442\u0435 \u0438 \u0436\u0434\u0451\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0451 \u0441\u0430\u043c\u043e \u0440\u0435\u0448\u0438\u0442\u0441\u044f (\u043d\u0435\u0442).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0444\u0430\u043d\u0430\u043c\u0438 \u0438 \u0434\u0430\u0442\u044c \u044e\u0437\u0435\u0440\u0430\u043c \u0447\u0442\u043e-\u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0436\u0435 \u043e\u0431\u0440\u044b\u0432\u0435 \u0441\u0432\u044f\u0437\u0438 \u2014 welcome to local-first apps. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443, \u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0441\u0435\u0431\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0431\u043e\u043d\u0443\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430 \u043d\u0435 \u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0430\u043b\u044c.<\/p>\n<h4>\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0442\u044d\u043a \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0439\u0442\u0438 \u0441 \u0443\u043c\u0430<\/h4>\n<ul>\n<li>\n<p>React Native \u2014 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u00ab\u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434 \u0432\u0441\u0451\u00bb \u0437\u0432\u0443\u0447\u0438\u0442 \u043a\u0440\u0443\u0442\u043e, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0447\u043d\u0451\u0448\u044c \u0434\u0435\u0431\u0430\u0436\u0438\u0442\u044c 15 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0445 \u0431\u0430\u0433\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>react-native-nitro-sqlite \u2014 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0438 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0437\u0430\u0431\u0438\u0442\u044c \u0432\u0441\u0451 \u043c\u043e\u043b\u043e\u0442\u043a\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>RxDB \u2014 \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u043a\u043e\u0448\u043c\u0430\u0440\u043e\u043c \u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043c\u0443\u0442\u0438\u0442\u044c \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0448\u0442\u0443\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>NestJS + TypeORM + PostgreSQL \u2014 \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0438\u0441\u0430\u043b SQL \u0440\u0443\u043a\u0430\u043c\u0438, \u0430 \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u00ab\u043a\u0440\u0443\u0442\u043e\u00bb \u0438 \u00ab\u0442\u0438\u043f\u0430\u00bb \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043b\u043e\u043a\u0430\u043b\u043a\u0438. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c \u043f\u0440\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u044b\u0442\u044c, \u043a\u0430\u043a \u043f\u043b\u043e\u0445\u043e \u0432\u0441\u0451 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e<\/h4>\n<pre><code class=\"typescript\">\/\/storage.ts import {   getRxStorageSQLiteTrial,   getSQLiteBasicsQuickSQLite, } from 'rxdb\/plugins\/storage-sqlite'; import { open } from 'react-native-nitro-sqlite'; import { wrappedValidateAjvStorage } from 'rxdb\/plugins\/validate-ajv'; import { wrappedKeyEncryptionCryptoJsStorage } from 'rxdb\/plugins\/encryption-crypto-js';  \/\/ \u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u0430\u0433\u0438\u044f \u2014 \u0431\u0435\u0440\u0451\u043c SQLite, \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u043c \u0438 \u0448\u0438\u0444\u0440\u0443\u0435\u043c. \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0442\u043e-\u0442\u043e \u0434\u0443\u043c\u0430\u0435\u0442, \u0447\u0442\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043a\u0440\u0443\u0442\u043e, \u0430 \u043d\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0433\u0435\u043c\u043e\u0440\u0440\u043e\u0439. const sqliteBasics = getSQLiteBasicsQuickSQLite(open); const storage = getRxStorageSQLiteTrial({ sqliteBasics }); const validatedStorage = wrappedValidateAjvStorage({ storage }); const encryptedStorage = wrappedKeyEncryptionCryptoJsStorage({   storage: validatedStorage, });  export { encryptedStorage }; <\/code><\/pre>\n<h4>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0430\u0437\u044b \u0438 \u043c\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u043e\u043c<\/h4>\n<pre><code class=\"typescript\">\/\/Instance.ts import { addRxPlugin, createRxDatabase, RxDatabase, WithDeleted } from 'rxdb'; import { RxDBDevModePlugin } from 'rxdb\/plugins\/dev-mode'; import { replicateRxCollection } from 'rxdb\/plugins\/replication'; import NetInfo from '@react-native-community\/netinfo'; import {   CheckPointType,   MyDatabaseCollections,   ReplicateCollectionDto, } from '.\/types.ts'; import { encryptedStorage } from '.\/storage.ts'; import { defaultConflictHandler } from '.\/utills.ts'; import { usersApi, userSchema, UserType } from '..\/features\/users'; import { RxDBMigrationSchemaPlugin } from 'rxdb\/plugins\/migration-schema'; import { RxDBQueryBuilderPlugin } from 'rxdb\/plugins\/query-builder'; import { RxDBUpdatePlugin } from 'rxdb\/plugins\/update';  \/\/ \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043b\u044e\u0431\u0438\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e: \u0437\u0434\u0435\u0441\u044c \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u0430\u043f\u0434\u0435\u0439\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u0438 \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043a\u043e\u043c\u0443-\u0442\u043e \u0436\u0435 \u043d\u0430\u0434\u043e \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f.  addRxPlugin(RxDBUpdatePlugin); addRxPlugin(RxDBQueryBuilderPlugin); addRxPlugin(RxDBMigrationSchemaPlugin);  export class RxDatabaseManager {   private static instance: RxDatabaseManager;   private db: RxDatabase&lt;MyDatabaseCollections&gt; | null = null;   private isOnline = false;    private constructor() {}    public static getInstance(): RxDatabaseManager {     if (!RxDatabaseManager.instance) {       \/\/ \u041e, \u0432\u043e\u043b\u0448\u0435\u0431\u0441\u0442\u0432\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u2014 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0445\u0430\u043e\u0441\u0430       RxDatabaseManager.instance = new RxDatabaseManager();     }     return RxDatabaseManager.instance;   }    public async init(): Promise&lt;RxDatabase&lt;MyDatabaseCollections&gt;&gt; {     if (this.db) return this.db;     if (__DEV__) {       \/\/ \u0412 \u0434\u0435\u0432\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u0431\u0430\u0433\u0438 \u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u0438 \u0442\u0430\u043a \u0445\u0432\u0430\u0442\u0430\u0435\u0442.       addRxPlugin(RxDBDevModePlugin);     }      this.db = await createRxDatabase&lt;MyDatabaseCollections&gt;({       name: 'myDb',       storage: encryptedStorage,       multiInstance: false, \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e React Native \u0438 \u043c\u0443\u043b\u044c\u0442\u0438-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u2014 \u044d\u0442\u043e \u0441\u0440\u043e\u0434\u043d\u0438 \u043f\u044b\u0442\u043a\u0435.       closeDuplicates: true, \/\/ \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0431\u0430\u0437\u0430 \u043d\u0435 \u0440\u0432\u0430\u043b\u0430 \u0432\u0430\u0448\u0438 \u043d\u0435\u0440\u0432\u044b.     });      await this.db.addCollections({       users: {         schema: userSchema,         conflictHandler: defaultConflictHandler, \/\/ \u041a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435, \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u0435\u043b\u044c\u0435.         migrationStrategies: {           \/\/ \u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043b\u044e\u0431\u0438\u0442 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430 \u043f\u043e\u0442\u043e\u043c.           \/\/ 1: function (oldDoc: UserType) {},         },       },     });      this.setupConnectivityListener(); \/\/ \u0427\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u00ab\u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043d\u043b\u0430\u0439\u043d\u00bb.      return this.db;   }    public getDb(): RxDatabase&lt;MyDatabaseCollections&gt; {     if (!this.db) {       throw new Error('Database not initialized. Call init() first.');       \/\/ \u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u044b \u0432\u0430\u043c \u0447\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u2014 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430, \u0430 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0434\u0435\u0439\u0442\u0435\u0441\u044c.     }     return this.db;   }    private replicateCollection&lt;T&gt;(dto: ReplicateCollectionDto&lt;T&gt;) {     const { collection, replicationId, api } = dto;     const replicationState = replicateRxCollection&lt;WithDeleted&lt;T&gt;, number&gt;({       collection: collection,       replicationIdentifier: replicationId,       pull: {         async handler(checkpointOrNull: unknown, batchSize: number) {           \/\/ \u041f\u0443\u043b\u043b\u0438\u043c \u043f\u0430\u0447\u043a\u0430\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u043f\u0430\u0441\u0442\u044c \u043e\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0435\u0449\u0451 \u0436\u0438\u0432.           const typedCheckpoint = checkpointOrNull as CheckPointType;           const updatedAt = typedCheckpoint ? typedCheckpoint.updatedAt : 0;           const id = typedCheckpoint ? typedCheckpoint.id : '';           const response = await api.pull({ updatedAt, id, batchSize });           return {             documents: response.data.documents,             checkpoint: response.data.checkpoint,           };         },         batchSize: 20, \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e 20 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e, \u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e\u00bb.       },       push: {         async handler(changeRows) {           console.log('push');           \/\/ \u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440,           \/\/ \u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u0432 \u0443\u0434\u0430\u0440\u0435, \u043b\u0438\u0431\u043e \u043c\u0451\u0440\u0442\u0432 \u2014 \u043f\u043e\u0444\u0438\u0433.           const response = await api.push({ changeRows });           return response.data;         },       },     }); <\/code><\/pre>\n<p>\u041a\u043e\u0440\u043e\u0447\u0435, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0441\u0434\u043e\u0445\u043b\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0436\u0435 \u043e\u0431\u0440\u044b\u0432\u0435 \u0441\u0432\u044f\u0437\u0438 \u2014 \u0443\u0447\u0438\u0442\u0435\u0441\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u043a\u0430\u0448\u0438 \u2014 \u043d\u0443, \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0443\u0439\u0434\u0443\u0442 \u043a \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0430\u043c.<\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043b\u043e\u0432\u043b\u044f \u043e\u0448\u0438\u0431\u043e\u043a (aka \u00ab\u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0441\u0451 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f\u00bb)<\/h4>\n<pre><code class=\"typescript\">private setupConnectivityListener() {   NetInfo.addEventListener((state) =&gt; {     this.isOnline = state.isConnected ?? false;     if (this.isOnline) {       \/\/ \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e.       this.startReplication();     } else {       \/\/ \u041d\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0436\u0430\u043b\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.       console.warn('\u041d\u0435\u0442 \u0441\u0432\u044f\u0437\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u043e\u0444\u0444\u043b\u0430\u0439\u043d\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u0432\u043e\u043b\u0435\u043d? \u041d\u0435\u0442.');     }   }); }  private startReplication() {   if (!this.db) {     console.error('\u0411\u0430\u0437\u0430 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u0430 \u0432\u044b \u0443\u0436\u0435 \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f? \u041c\u043e\u043b\u043e\u0434\u0435\u0446.');     return;   }    \/\/ \u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 users \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043c\u0438\u043d\u0438-\u043f\u0435\u0440\u0444\u043e\u0440\u043c\u0430\u043d\u0441 \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.   const usersCollection = this.db.users;   if (!usersCollection) {     console.error('\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f users \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430, \u043f\u0440\u0438\u0432\u0435\u0442 \u0431\u0430\u0433\u0430\u043c.');     return;   }    this.replicateCollection&lt;UserType&gt;({     collection: usersCollection,     replicationId: 'users-replication',     api: usersApi,   }); } <\/code><\/pre>\n<h4>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u2014 \u0438\u043b\u0438 \u043a\u0430\u043a \u0432\u044b\u0436\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/h4>\n<pre><code class=\"typescript\">export const defaultConflictHandler = async (input: {   realMasterState: any;   newDocumentState: any;   realMasterStateLastWriteTime: number; }) =&gt; {   \/\/ \u0422\u0443\u0442 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043c: \"\u0414\u0435\u0440\u0436\u0438, \u0432\u043e\u0442 \u0442\u0432\u043e\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0436\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0441\u043f\u043e\u0440\u0438\u0442\"   \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u2014 \u044d\u0442\u043e \u0434\u043b\u044f \u0441\u043b\u0430\u0431\u0430\u043a\u043e\u0432.   return {     isEqual: false,     documentData: input.realMasterState,   }; }; <\/code><\/pre>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0438\u0448\u0435\u0442<\/h4>\n<pre><code class=\"typescript\">migrationStrategies: {   1: function (oldDoc: UserType) {     \/\/ \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0438\u0434, \u0447\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u043c \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u0445,     \/\/ \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u043f\u0434\u0435\u0439\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u0441\u043d\u043e\u0432\u0430 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f.     return oldDoc;   }, } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u0442\u043e \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e \u2014 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u043d\u0430\u0447\u0430\u043b\u0438 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f. \u0420\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c, \u0438 \u0442\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043d\u0430\u0441 \u0441 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<h4>\u0421\u043e\u0432\u0435\u0442 \u043e\u0442 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441 \u0433\u043e\u0440\u044c\u043a\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c<\/h4>\n<ul>\n<li>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043d\u0430\u0434\u0435\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0434\u043e\u0436\u0434\u0451\u0442, \u043f\u043e\u043a\u0430 \u0432\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0439\u0442\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u2014 \u0431\u0430\u0433\u0438 \u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u2014 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u0438\u0433\u0440\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 RxDB.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u0443\u0442 \u0435\u0449\u0451 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u0431\u043e\u0438\u0442\u0435\u0441\u044c \u0436\u0451\u0441\u0442\u043a\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0430\u0448 \u0441\u043e\u0432\u0435\u0442: \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0439\u0442\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0441 \u0437\u0430\u043f\u0430\u0441\u043e\u043c \u043f\u0440\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u0433\u043e\u0442\u043e\u0432\u044c\u0442\u0435\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u043e\u043f\u0438\u043b\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u044e\u0437\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0444\u0444\u043b\u0430\u0439\u043d.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/935798\/\"> https:\/\/habr.com\/ru\/articles\/935798\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435: \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. \u041d\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430? \u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e, \u0443 \u0432\u0430\u0441 \u043c\u0451\u0440\u0442\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043a\u0443\u0447\u0430 \u043d\u0435\u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0443 \u0438\u043b\u0438 \u043a\u0443\u0440\u044c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u043e\u0438\u0442 \u043a\u0430\u043a \u0434\u0443\u0440\u0430\u043a \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u043b\u043e. \u0411\u0438\u0437\u043d\u0435\u0441 \u0441\u0442\u043e\u0438\u0442, \u0430 \u0432\u044b \u0441\u0438\u0434\u0438\u0442\u0435 \u0438 \u0436\u0434\u0451\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0451 \u0441\u0430\u043c\u043e \u0440\u0435\u0448\u0438\u0442\u0441\u044f (\u043d\u0435\u0442).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0444\u0430\u043d\u0430\u043c\u0438 \u0438 \u0434\u0430\u0442\u044c \u044e\u0437\u0435\u0440\u0430\u043c \u0447\u0442\u043e-\u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0436\u0435 \u043e\u0431\u0440\u044b\u0432\u0435 \u0441\u0432\u044f\u0437\u0438 \u2014 welcome to local-first apps. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443, \u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0441\u0435\u0431\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u0431\u043e\u043d\u0443\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430 \u043d\u0435 \u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0430\u043b\u044c.<\/p>\n<h4>\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0442\u044d\u043a \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0439\u0442\u0438 \u0441 \u0443\u043c\u0430<\/h4>\n<ul>\n<li>\n<p>React Native \u2014 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u00ab\u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434 \u0432\u0441\u0451\u00bb \u0437\u0432\u0443\u0447\u0438\u0442 \u043a\u0440\u0443\u0442\u043e, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0447\u043d\u0451\u0448\u044c \u0434\u0435\u0431\u0430\u0436\u0438\u0442\u044c 15 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0445 \u0431\u0430\u0433\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>react-native-nitro-sqlite \u2014 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0438 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0437\u0430\u0431\u0438\u0442\u044c \u0432\u0441\u0451 \u043c\u043e\u043b\u043e\u0442\u043a\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>RxDB \u2014 \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u043a\u043e\u0448\u043c\u0430\u0440\u043e\u043c \u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043c\u0443\u0442\u0438\u0442\u044c \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0448\u0442\u0443\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>NestJS + TypeORM + PostgreSQL \u2014 \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0438\u0441\u0430\u043b SQL \u0440\u0443\u043a\u0430\u043c\u0438, \u0430 \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u00ab\u043a\u0440\u0443\u0442\u043e\u00bb \u0438 \u00ab\u0442\u0438\u043f\u0430\u00bb \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043b\u043e\u043a\u0430\u043b\u043a\u0438. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c \u043f\u0440\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u044b\u0442\u044c, \u043a\u0430\u043a \u043f\u043b\u043e\u0445\u043e \u0432\u0441\u0451 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e<\/h4>\n<pre><code class=\"typescript\">\/\/storage.ts import {   getRxStorageSQLiteTrial,   getSQLiteBasicsQuickSQLite, } from 'rxdb\/plugins\/storage-sqlite'; import { open } from 'react-native-nitro-sqlite'; import { wrappedValidateAjvStorage } from 'rxdb\/plugins\/validate-ajv'; import { wrappedKeyEncryptionCryptoJsStorage } from 'rxdb\/plugins\/encryption-crypto-js';  \/\/ \u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u0430\u0433\u0438\u044f \u2014 \u0431\u0435\u0440\u0451\u043c SQLite, \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u043c \u0438 \u0448\u0438\u0444\u0440\u0443\u0435\u043c. \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0442\u043e-\u0442\u043e \u0434\u0443\u043c\u0430\u0435\u0442, \u0447\u0442\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043a\u0440\u0443\u0442\u043e, \u0430 \u043d\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0433\u0435\u043c\u043e\u0440\u0440\u043e\u0439. const sqliteBasics = getSQLiteBasicsQuickSQLite(open); const storage = getRxStorageSQLiteTrial({ sqliteBasics }); const validatedStorage = wrappedValidateAjvStorage({ storage }); const encryptedStorage = wrappedKeyEncryptionCryptoJsStorage({   storage: validatedStorage, });  export { encryptedStorage }; <\/code><\/pre>\n<h4>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0430\u0437\u044b \u0438 \u043c\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u043e\u043c<\/h4>\n<pre><code class=\"typescript\">\/\/Instance.ts import { addRxPlugin, createRxDatabase, RxDatabase, WithDeleted } from 'rxdb'; import { RxDBDevModePlugin } from 'rxdb\/plugins\/dev-mode'; import { replicateRxCollection } from 'rxdb\/plugins\/replication'; import NetInfo from '@react-native-community\/netinfo'; import {   CheckPointType,   MyDatabaseCollections,   ReplicateCollectionDto, } from '.\/types.ts'; import { encryptedStorage } from '.\/storage.ts'; import { defaultConflictHandler } from '.\/utills.ts'; import { usersApi, userSchema, UserType } from '..\/features\/users'; import { RxDBMigrationSchemaPlugin } from 'rxdb\/plugins\/migration-schema'; import { RxDBQueryBuilderPlugin } from 'rxdb\/plugins\/query-builder'; import { RxDBUpdatePlugin } from 'rxdb\/plugins\/update';  \/\/ \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043b\u044e\u0431\u0438\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e: \u0437\u0434\u0435\u0441\u044c \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u0430\u043f\u0434\u0435\u0439\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u0438 \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2014 \u043a\u043e\u043c\u0443-\u0442\u043e \u0436\u0435 \u043d\u0430\u0434\u043e \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f.  addRxPlugin(RxDBUpdatePlugin); addRxPlugin(RxDBQueryBuilderPlugin); addRxPlugin(RxDBMigrationSchemaPlugin);  export class RxDatabaseManager {   private static instance: RxDatabaseManager;   private db: RxDatabase&lt;MyDatabaseCollections&gt; | null = null;   private isOnline = false;    private constructor() {}    public static getInstance(): RxDatabaseManager {     if (!RxDatabaseManager.instance) {       \/\/ \u041e, \u0432\u043e\u043b\u0448\u0435\u0431\u0441\u0442\u0432\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0430 \u2014 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0445\u0430\u043e\u0441\u0430       RxDatabaseManager.instance = new RxDatabaseManager();     }     return RxDatabaseManager.instance;   }    public async init(): Promise&lt;RxDatabase&lt;MyDatabaseCollections&gt;&gt; {     if (this.db) return this.db;     if (__DEV__) {       \/\/ \u0412 \u0434\u0435\u0432\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u043b\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u0431\u0430\u0433\u0438 \u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u0438 \u0442\u0430\u043a \u0445\u0432\u0430\u0442\u0430\u0435\u0442.       addRxPlugin(RxDBDevModePlugin);     }      this.db = await createRxDatabase&lt;MyDatabaseCollections&gt;({       name: 'myDb',       storage: encryptedStorage,       multiInstance: false, \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e React Native \u0438 \u043c\u0443\u043b\u044c\u0442\u0438-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u2014 \u044d\u0442\u043e \u0441\u0440\u043e\u0434\u043d\u0438 \u043f\u044b\u0442\u043a\u0435.       closeDuplicates: true, \/\/ \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0431\u0430\u0437\u0430 \u043d\u0435 \u0440\u0432\u0430\u043b\u0430 \u0432\u0430\u0448\u0438 \u043d\u0435\u0440\u0432\u044b.     });      await this.db.addCollections({       users: {         schema: userSchema,         conflictHandler: defaultConflictHandler, \/\/ \u041a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435, \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0441\u0435\u043b\u044c\u0435.         migrationStrategies: {           \/\/ \u041c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043b\u044e\u0431\u0438\u0442 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430 \u043f\u043e\u0442\u043e\u043c.           \/\/ 1: function (oldDoc: UserType) {},         },       },     });      this.setupConnectivityListener(); \/\/ \u0427\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u00ab\u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043d\u043b\u0430\u0439\u043d\u00bb.      return this.db;   }    public getDb(): RxDatabase&lt;MyDatabaseCollections&gt; {     if (!this.db) {       throw new Error('Database not initialized. Call init() first.');       \/\/ \u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u044b \u0432\u0430\u043c \u0447\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u2014 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430, \u0430 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0434\u0435\u0439\u0442\u0435\u0441\u044c.     }     return this.db;   }    private replicateCollection&lt;T&gt;(dto: ReplicateCollectionDto&lt;T&gt;) {     const { collection, replicationId, api } = dto;     const replicationState = replicateRxCollection&lt;WithDeleted&lt;T&gt;, number&gt;({       collection: collection,       replicationIdentifier: replicationId,       pull: {         async handler(checkpointOrNull: unknown, batchSize: number) {           \/\/ \u041f\u0443\u043b\u043b\u0438\u043c \u043f\u0430\u0447\u043a\u0430\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u043f\u0430\u0441\u0442\u044c \u043e\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0435\u0449\u0451 \u0436\u0438\u0432.           const typedCheckpoint = checkpointOrNull as CheckPointType;           const updatedAt = typedCheckpoint ? typedCheckpoint.updatedAt : 0;           const id = typedCheckpoint ? typedCheckpoint.id : '';           const response = await api.pull({ updatedAt, id, batchSize });           return {             documents: response.data.documents,             checkpoint: response.data.checkpoint,           };         },         batchSize: 20, \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e 20 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e, \u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e\u00bb.       },       push: {         async handler(changeRows) {           console.log('push');           \/\/ \u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440,           \/\/ \u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0431\u043e \u0432 \u0443\u0434\u0430\u0440\u0435, \u043b\u0438\u0431\u043e \u043c\u0451\u0440\u0442\u0432 \u2014 \u043f\u043e\u0444\u0438\u0433.           const response = await api.push({ changeRows });           return response.data;         },       },     }); <\/code><\/pre>\n<p>\u041a\u043e\u0440\u043e\u0447\u0435, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0441\u0434\u043e\u0445\u043b\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0436\u0435 \u043e\u0431\u0440\u044b\u0432\u0435 \u0441\u0432\u044f\u0437\u0438 \u2014 \u0443\u0447\u0438\u0442\u0435\u0441\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u043a\u0430\u0448\u0438 \u2014 \u043d\u0443, \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0443\u0439\u0434\u0443\u0442 \u043a \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0430\u043c.<\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043b\u043e\u0432\u043b\u044f \u043e\u0448\u0438\u0431\u043e\u043a (aka \u00ab\u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0441\u0451 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f\u00bb)<\/h4>\n<pre><code class=\"typescript\">private setupConnectivityListener() {   NetInfo.addEventListener((state) =&gt; {     this.isOnline = state.isConnected ?? false;     if (this.isOnline) {       \/\/ \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e.       this.startReplication();     } else {       \/\/ \u041d\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0436\u0430\u043b\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.       console.warn('\u041d\u0435\u0442 \u0441\u0432\u044f\u0437\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 \u043e\u0444\u0444\u043b\u0430\u0439\u043d\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u0432\u043e\u043b\u0435\u043d? \u041d\u0435\u0442.');     }   }); }  private startReplication() {   if (!this.db) {     console.error('\u0411\u0430\u0437\u0430 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u0430 \u0432\u044b \u0443\u0436\u0435 \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f? \u041c\u043e\u043b\u043e\u0434\u0435\u0446.');     return;   }    \/\/ \u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 users \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043c\u0438\u043d\u0438-\u043f\u0435\u0440\u0444\u043e\u0440\u043c\u0430\u043d\u0441 \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.   const usersCollection = this.db.users;   if (!usersCollection) {     console.error('\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f users \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430, \u043f\u0440\u0438\u0432\u0435\u0442 \u0431\u0430\u0433\u0430\u043c.');     return;   }    this.replicateCollection&lt;UserType&gt;({     collection: usersCollection,     replicationId: 'users-replication',     api: usersApi,   }); } <\/code><\/pre>\n<h4>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u2014 \u0438\u043b\u0438 \u043a\u0430\u043a \u0432\u044b\u0436\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/h4>\n<pre><code class=\"typescript\">export const defaultConflictHandler = async (input: {   realMasterState: any;   newDocumentState: any;   realMasterStateLastWriteTime: number; }) =&gt; {   \/\/ \u0422\u0443\u0442 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043c: \"\u0414\u0435\u0440\u0436\u0438, \u0432\u043e\u0442 \u0442\u0432\u043e\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0436\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0441\u043f\u043e\u0440\u0438\u0442\"   \/\/ \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u2014 \u044d\u0442\u043e \u0434\u043b\u044f \u0441\u043b\u0430\u0431\u0430\u043a\u043e\u0432.   return {     isEqual: false,     documentData: input.realMasterState,   }; }; <\/code><\/pre>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0438\u0448\u0435\u0442<\/h4>\n<pre><code class=\"typescript\">migrationStrategies: {   1: function (oldDoc: UserType) {     \/\/ \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0438\u0434, \u0447\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u043c \u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u0445,     \/\/ \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u043f\u0434\u0435\u0439\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u0441\u043d\u043e\u0432\u0430 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f.     return oldDoc;   }, } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u0442\u043e \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e \u2014 \u0432\u044b \u0435\u0449\u0451 \u043d\u0435 \u043d\u0430\u0447\u0430\u043b\u0438 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f. \u0420\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c, \u0438 \u0442\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043d\u0430\u0441 \u0441 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<h4>\u0421\u043e\u0432\u0435\u0442 \u043e\u0442 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441 \u0433\u043e\u0440\u044c\u043a\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c<\/h4>\n<ul>\n<li>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043d\u0430\u0434\u0435\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0434\u043e\u0436\u0434\u0451\u0442, \u043f\u043e\u043a\u0430 \u0432\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0439\u0442\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u2014 \u0431\u0430\u0433\u0438 \u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u2014 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u0438\u0433\u0440\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 RxDB.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u0443\u0442 \u0435\u0449\u0451 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u0431\u043e\u0438\u0442\u0435\u0441\u044c \u0436\u0451\u0441\u0442\u043a\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0430\u0448 \u0441\u043e\u0432\u0435\u0442: \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0439\u0442\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0441 \u0437\u0430\u043f\u0430\u0441\u043e\u043c \u043f\u0440\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u0433\u043e\u0442\u043e\u0432\u044c\u0442\u0435\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u043e\u043f\u0438\u043b\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u044e\u0437\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0444\u0444\u043b\u0430\u0439\u043d.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/935798\/\"> https:\/\/habr.com\/ru\/articles\/935798\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-470192","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/470192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=470192"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/470192\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=470192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=470192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=470192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}