Meteor-Community-Packages/meteor-schema-index

Error 500 when duplicate field found

Opened this issue · 1 comments

If I set unique value and try to insert a same value throwing an error 500

'slug': {
        type: String,
        unique: true
    },

Client Error:

Error: Internal server error [500]
    at Connection._livedata_result (http://localhost:3000/packages/ddp-client.js?hash=69c1d15adcf9b913cb4704b652adeff4bc462aa8:1975:25)
    at Connection.onMessage (http://localhost:3000/packages/ddp-client.js?hash=69c1d15adcf9b913cb4704b652adeff4bc462aa8:2169:14)
    at http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:262:13
    at Array.forEach (<anonymous>)
    at ClientStream.forEachCallback (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:353:33)
    at SockJS.socket.onmessage (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:261:18)
    at SockJS.REventTarget.dispatchEvent (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:641:22)
    at SockJS._dispatchMessage (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:1820:10)
    at SockJS._didMessage (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:1886:16)
    at WebSocket.that.ws.onmessage (http://localhost:3000/packages/socket-stream-client.js?hash=7063aa833005aff7419b3f8c222e877582f1a3e0:2044:15)

Server error:

 Exception while invoking method 'categories.update' MongoError: E11000 duplicate key error collection: meteor.category index: c2_slugIt dup key: { : "prova" }
     at Function.MongoError.create (/Users/user/.meteor/packages/npm-mongo/.2.2.33.1b95sy0++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/error.js:31:11)
     at toError (/Users/user/.meteor/packages/npm-mongo/.2.2.33.1b95sy0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/utils.js:139:22)
     at /Users/user/.meteor/packages/npm-mongo/.2.2.33.1b95sy0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/collection.js:1059:67
     at /Users/user/.meteor/packages/npm-mongo/.2.2.33.1b95sy0++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:469:18
     at _combinedTickCallback (internal/process/next_tick.js:131:7)
     at process._tickDomainCallback (internal/process/next_tick.js:218:9)

How to manage this error?

I use:

"simpl-schema": "^1.4.2"
aldeed:collection2     3.0.0
aldeed:schema-index    3.0.0

I expected to get an error kind so 400 'notUnique'