pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/
https://rxdb.info/
Apache License 2.0
21.12k stars 1.03k forks source link

Memory adapter - inMemory() throws error: `_id is required for puts` #401

Closed adamJLev closed 6 years ago

adamJLev commented 6 years ago

Issue

Getting Uncaught (in promise) CustomPouchError {status: 412, name: "missing_id", message: "_id is required for puts", error: true} right after calling db.collectionName.inMemory().

Info

Code

I can reproduce it using the local example project by modifying the heroes-list.vue:mounted() function to look like this:

    mounted: async function() {
        const db = await Database.get();
        const col = await db.heroes.inMemory();

        this.subs.push(
            col
            .find().$
            .filter(x => x != null)
            .subscribe(results => {
                console.log('results:');
                //                console.dir(results);
                this.results = results;
            })
        );
    },

And added this to the top of Database.js

RxDB.plugin(require('pouchdb-adapter-memory'));

Thanks!

pubkey commented 6 years ago

Hi @adamJLev can you post your schema?

adamJLev commented 6 years ago

@pubkey I'm just using the example vue project to reproduce the issue - the only change I made is the 2 things I posted in the issue. https://github.com/pubkey/rxdb/tree/master/examples/vue

so this is the schema: https://github.com/pubkey/rxdb/blob/master/examples/vue/src/database/HeroSchema.js

pubkey commented 6 years ago

Could reproduce, fix will follow soon