                 @_addCreatedAt data
 
                 @_dataSource.bucket.insert newId, data, options, (error, result) ->
-                    return callback error if error
+                    return callback error if error?
                     return callback null, result
 
             if validate and @_validate?


        idWithPrefix = "#{@_keyPrefix}#{id}"
        @_dataSource.bucket.remove idWithPrefix, options, (error, result) ->
            return callback error if error
            return callback null, result

    # Inserts a single record using the primary key, it updates if the key already exists

            @_addLastUpdate data

            @_dataSource.bucket.replace idWithPrefix, data, options, (error, result) ->
                return callback error if error?
                return callback null, result

        if validate and @_validate?
