{"action":"created","issue":{"url":"https://api.github.com/repos/pubkey/rxdb/issues/319","repository_url":"https://api.github.com/repos/pubkey/rxdb","labels_url":"https://api.github.com/repos/pubkey/rxdb/issues/319/labels{/name}","comments_url":"https://api.github.com/repos/pubkey/rxdb/issues/319/comments","events_url":"https://api.github.com/repos/pubkey/rxdb/issues/319/events","html_url":"https://github.com/pubkey/rxdb/issues/319","id":264158364,"number":319,"title":"Database may need to  dump the whole db include the collections' schema","user":{"login":"KeZhang","id":1009626,"avatar_url":"https://avatars1.githubusercontent.com/u/1009626?v=4","gravatar_id":"","url":"https://api.github.com/users/KeZhang","html_url":"https://github.com/KeZhang","followers_url":"https://api.github.com/users/KeZhang/followers","following_url":"https://api.github.com/users/KeZhang/following{/other_user}","gists_url":"https://api.github.com/users/KeZhang/gists{/gist_id}","starred_url":"https://api.github.com/users/KeZhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KeZhang/subscriptions","organizations_url":"https://api.github.com/users/KeZhang/orgs","repos_url":"https://api.github.com/users/KeZhang/repos","events_url":"https://api.github.com/users/KeZhang/events{/privacy}","received_events_url":"https://api.github.com/users/KeZhang/received_events","type":"User","site_admin":false},"labels":[{"id":493376746,"url":"https://api.github.com/repos/pubkey/rxdb/labels/bug","name":"bug","color":"ee0701","default":true},{"id":611667268,"url":"https://api.github.com/repos/pubkey/rxdb/labels/has%20test%20case","name":"has test case","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-10-10T09:29:21Z","updated_at":"2017-10-10T15:46:04Z","closed_at":null,"author_association":"NONE","body":"<!-- REMOVE EVERYTHING WRITTEN IN UPPERCASE -->\r\n\r\n<!-- IMPORTANT:\r\nIf you have a common question which cannot be solved with a PR, ask it here https://gitter.im/pubkey/rxdb\r\n-->\r\n\r\n## Case\r\n<!-- IS IT A BUG OR A REQUEST FOR A NEW FEATURE?-->\r\nBUG\r\n\r\n## Issue\r\n<!-- DESCRIBE WHY YOU OPEN THIS ISSUE -->\r\nWhen I try to use dump / importDump for the whole database, I must prepare all the collections in the destination database, or it can't import the data\r\n## Info\r\n- Environment: (Node.js/browser/electron/etc.)\r\n- Adapter: (IndexedDB/Localstorage/LevelDB/etc.)\r\n\r\n## Code\r\n```\r\nconst assert = require('assert');\r\nconst RxDatabase = require('rxdb');\r\nRxDatabase.plugin(require('pouchdb-adapter-memory'));\r\n\r\nconst docSchema = {\r\n    name: 'demo',\r\n    version: 0,\r\n    properties: {\r\n        firstName: {\r\n            primary: true,\r\n            type: 'string'\r\n        },\r\n        time: {\r\n            type: 'string'\r\n        }\r\n    }\r\n};\r\nasync function test() {\r\n    const db = await RxDatabase.create({\r\n        name: 'aaa',\r\n        adapter: 'memory',\r\n    });\r\n    const db2 = await RxDatabase.create({\r\n        name: 'aaa1',\r\n        adapter: 'memory',\r\n    });\r\n  const col = await db.collection({\r\n        name: 'demo',\r\n        schema: docSchema\r\n    });\r\n\r\n    col.insert({ firstName: 'nnnn' });\r\n\r\n    const json = await db.dump();\r\n\r\n    await db2.importDump(json).then((r) => {\r\n        console.log('=======db=========done=====');\r\n        console.dir(r);\r\n    });\r\n    //!!! The collections must be created before importDump \r\n    const col2 = await db2.collection({\r\n        name: 'demo',\r\n        schema: docSchema\r\n    });\r\n\r\n    const docs = await col2.find().exec();\r\n\r\n    assert.equal(docs.length, 1);\r\n    db.destroy();\r\n    db2.destroy();\r\n}\r\ntest();\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pubkey/rxdb/issues/comments/335517294","html_url":"https://github.com/pubkey/rxdb/issues/319#issuecomment-335517294","issue_url":"https://api.github.com/repos/pubkey/rxdb/issues/319","id":335517294,"user":{"login":"pubkey","id":8926560,"avatar_url":"https://avatars3.githubusercontent.com/u/8926560?v=4","gravatar_id":"","url":"https://api.github.com/users/pubkey","html_url":"https://github.com/pubkey","followers_url":"https://api.github.com/users/pubkey/followers","following_url":"https://api.github.com/users/pubkey/following{/other_user}","gists_url":"https://api.github.com/users/pubkey/gists{/gist_id}","starred_url":"https://api.github.com/users/pubkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubkey/subscriptions","organizations_url":"https://api.github.com/users/pubkey/orgs","repos_url":"https://api.github.com/users/pubkey/repos","events_url":"https://api.github.com/users/pubkey/events{/privacy}","received_events_url":"https://api.github.com/users/pubkey/received_events","type":"User","site_admin":false},"created_at":"2017-10-10T15:46:04Z","updated_at":"2017-10-10T15:46:04Z","author_association":"OWNER","body":"Hmm.\r\nWhen the collection does not exist, the import on the collection will not work.\r\nWe could now include the collection-schema into the export so we can create the collection on import if it does not exist.\r\nBut this will create strange behavior because we do not know about the other collection-settings like `migrationStrategies` or the orm-methods.\r\n\r\n\r\n"}}
{"actor":{"display_login":"pubkey"}}