Giter Site home page Giter Site logo

hmve's People

Stargazers

 avatar  avatar

Watchers

 avatar

hmve's Issues

checking for unique fields is not supported for bulk writing (eg: insertMany)

hmve is working well when validating unique fields errors for single items being post to the mognodb.
in simple other words:

const { Schema, model } = require('mongoose')
const schema = new Schema({
    name: {
        type: String,
        unique: true
    }
})

const Model = model('x', schema)

Model.create( { name: "first" } ) // works!
// ... after some time
Model.create( { name: "first" } ) // hmve detects that this is a duplicate field, good ๐Ÿ‘๏ธ, hmve is working

however, if you want to save in a bulk, ie, save multiple documents at the same time, hmve is not going to see that there is duplicate fields:

Model.insertMany( [ {  name: "first" }, {  name: "first" }, {  name: "first" } ] ) // hmve didn't recognize that, and the output on the console of the error is: 
// BulkWriteError: E11000 duplicate key error collection

I know that hmve only validates for mongoose validation errors, but this should be also supported, since the developer would probably rely on hmve for this kind of job.

Cast Errors are considered validation errors

You should add a way to exclude fields from being handled by hmve, after reading the readme.md, you're showing how to execlude error types such as "required, min, max..." but what about excluding some fields from being checked by hmve such as "username" and "email".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.