scottwrobinson / camo

A class-based ES6 ODM for Mongo-like databases.
556 stars 80 forks source link

Why can't there just be an upsert method on Document? #103

Open lurchpop opened 7 years ago

lurchpop commented 7 years ago

What's the reason Document can't have this method?

    static upsert(query, update){
        return this.findOne(query).then(doc=>{
            return Object.assign(doc, update).save();
        });
    }

Why the findOneAndUpdate(.., .., {upsert:true}) garbage where the save hooks don't even get called?