Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 无法运行RxDb迁移策略_Reactjs_Redux_Pouchdb_Rxdb - Fatal编程技术网

Reactjs 无法运行RxDb迁移策略

Reactjs 无法运行RxDb迁移策略,reactjs,redux,pouchdb,rxdb,Reactjs,Redux,Pouchdb,Rxdb,我正在尝试实施一个简单的迁移策略,如以下文档所述: 我想知道是否有人成功实施了迁移策略,因为我在网上找不到任何例子,或者我只是在浪费时间 当我尝试传入一个对象(如文档所述)时,会出现以下错误: RxError:RxError:migrationStrategies必须是未捕获的函数(承诺)>RxError:RxError:migrationStrategy必须是函数 当我尝试将策略作为函数传递时,我得到以下错误: RxError:RxError:migrationStrategies必须是对象构

我正在尝试实施一个简单的迁移策略,如以下文档所述:

我想知道是否有人成功实施了迁移策略,因为我在网上找不到任何例子,或者我只是在浪费时间

当我尝试传入一个对象(如文档所述)时,会出现以下错误:

RxError:RxError:migrationStrategies必须是未捕获的函数(承诺)>RxError:RxError:migrationStrategy必须是函数

当我尝试将策略作为函数传递时,我得到以下错误:

RxError:RxError:migrationStrategies必须是对象构造。js:30未捕获(承诺)RxError:RxError:migrationStrategies必须是对象

实际结果:当作为上述函数传入迁移策略时,我得到以下错误消息:

RxError: RxError: migrationStrategies must be an object
construct.js:30 Uncaught (in promise) RxError: RxError:
migrationStrategies must be an object
Given parameters: {
schema:{
  "jsonID": {
    "title": "Cookie",
    "description": "Database schema for a cookie",
    "version": 6,
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "primary": true
      },
      "flavour": {
        "type": "string"
      },
      "someNewProperty": {
        "type": "string"
      },
      "flavor": {
        "type": "string"
      },
      "_rev": {
        "type": "string",
        "minLength": 1
      },
      "_attachments": {
        "type": "object"
      }
    },
    "required": [
      "someNewProperty",
      "flavour",
      "id"
    ],
    "additionalProperties": false,
    "keyCompression": false,
    "compoundIndexes": []
  },
  "compoundIndexes": [],
  "indexes": [],
  "primaryPath": "id",
  "finalFields": [
    "id"
  ],
  "_normalized": {
    "additionalProperties": false,
    "compoundIndexes": [],
    "description": "Database schema for a cookie",
    "keyCompression": false,
    "properties": {
      "_attachments": {
        "type": "object"
      },
      "_rev": {
        "minLength": 1,
        "type": "string"
      },
      "flavor": {
        "type": "string"
      },
      "flavour": {
        "type": "string"
      },
      "id": {
        "primary": true,
        "type": "string"
      },
      "someNewProperty": {
        "type": "string"
      }
    },
    "required": [
      "flavour",
      "id",
      "someNewProperty"
    ],
    "title": "Cookie",
    "type": "object",
    "version": 6
  },
  "_hash": "2be159496392dec24c2a70e26094c600"
}}


我认为ID为0的第一个迁移策略没有任何意义我认为ID为0的第一个迁移策略没有任何意义
    Error in console:  RxError: RxError:
    migrationStrategies must be a function

    Uncaught (in promise) RxError: RxError:
    migrationStrategy must be a function
    Given parameters: {
    version:5
    type:"object"
    schema:{
      "jsonID": {
        "title": "Cookie",
        "description": "Database schema for a cookie",
        "version": 6,
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "primary": true
          },
          "flavour": {
            "type": "string"
          },
          "someNewProperty": {
            "type": "string"
          },
          "flavor": {
            "type": "string"
          },
          "_rev": {
            "type": "string",
            "minLength": 1
          },
          "_attachments": {
            "type": "object"
          }
        },
        "required": [
          "someNewProperty",
          "flavour",
          "id"
        ],
        "additionalProperties": false,
        "keyCompression": false,
        "compoundIndexes": []
      },
      "compoundIndexes": [],
      "indexes": [],
      "primaryPath": "id",
      "finalFields": [
        "id"
      ],
      "_normalized": {
        "additionalProperties": false,
        "compoundIndexes": [],
        "description": "Database schema for a cookie",
        "keyCompression": false,
        "properties": {
          "_attachments": {
            "type": "object"
          },
          "_rev": {
            "minLength": 1,
            "type": "string"
          },
          "flavor": {
            "type": "string"
          },
          "flavour": {
            "type": "string"
          },
          "id": {
            "primary": true,
            "type": "string"
          },
          "someNewProperty": {
            "type": "string"
          }
        },
        "required": [
          "flavour",
          "id",
          "someNewProperty"
        ],
        "title": "Cookie",
        "type": "object",
        "version": 6
      },
      "_hash": "2be159496392dec24c2a70e26094c600"
    }}


      migrationStrategies: () => {
            return {
              0: function(oldDoc) {
                return oldDoc
              },
              // 1 means, this transforms data from version 0 to version 1
              1: function(oldDoc) {
                return oldDoc
              },
              2: function(oldDoc) {
                return oldDoc
              },
              3: function(oldDoc) {
                return oldDoc
              },
              4: function(oldDoc) {
                return oldDoc
              },
              5: function(oldDoc) {
                oldDoc.someNewProperty = oldDoc.flavor
                oldDoc.flavour = oldDoc.someNewProperty
              },
            }
            // 6: function(oldDoc) {
            //   oldDoc.someNewProperty = oldDoc.flavor
            //   return oldDoc
            // },
            // 7: function(oldDoc) {
            //   oldDoc.flavour = oldDoc.someNewProperty
            //   return oldDoc
            // },
          },
RxError: RxError: migrationStrategies must be an object
construct.js:30 Uncaught (in promise) RxError: RxError:
migrationStrategies must be an object
Given parameters: {
schema:{
  "jsonID": {
    "title": "Cookie",
    "description": "Database schema for a cookie",
    "version": 6,
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "primary": true
      },
      "flavour": {
        "type": "string"
      },
      "someNewProperty": {
        "type": "string"
      },
      "flavor": {
        "type": "string"
      },
      "_rev": {
        "type": "string",
        "minLength": 1
      },
      "_attachments": {
        "type": "object"
      }
    },
    "required": [
      "someNewProperty",
      "flavour",
      "id"
    ],
    "additionalProperties": false,
    "keyCompression": false,
    "compoundIndexes": []
  },
  "compoundIndexes": [],
  "indexes": [],
  "primaryPath": "id",
  "finalFields": [
    "id"
  ],
  "_normalized": {
    "additionalProperties": false,
    "compoundIndexes": [],
    "description": "Database schema for a cookie",
    "keyCompression": false,
    "properties": {
      "_attachments": {
        "type": "object"
      },
      "_rev": {
        "minLength": 1,
        "type": "string"
      },
      "flavor": {
        "type": "string"
      },
      "flavour": {
        "type": "string"
      },
      "id": {
        "primary": true,
        "type": "string"
      },
      "someNewProperty": {
        "type": "string"
      }
    },
    "required": [
      "flavour",
      "id",
      "someNewProperty"
    ],
    "title": "Cookie",
    "type": "object",
    "version": 6
  },
  "_hash": "2be159496392dec24c2a70e26094c600"
}}