                 @_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}"

        afterValidate = (error = null) =>
            return callback(error) if error

            if match and @_validate?
                matched = @_validator.match data

    # @param {string} id The record id
    # @param {function} callback Called when the operation is completed (error, result)
    findById: (id, callback) ->
        idWithPrefix = "#{@_keyPrefix}#{id}"
        @_dataSource.bucket.get idWithPrefix, (error, result) ->
            return callback error if error?
            return callback null, result

    # Finds many records using the primary key
    # @param {array|string} ids The records id within an array of Strings
