How to use the parse-server/lib/Adapters/Storage/Mongo/MongoTransform.parseObjectToMongoObjectForCreate function in parse-server

To help you get started, we’ve selected a few parse-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github benishak / parse-server-dynamodb-adapter / src / Adapter.ts View on Github external
createObject(className, schema, object) : Promise {
        object = this.transformDateObject(object);
        schema = Transform.convertParseSchemaToMongoSchema(schema);
        object = Transform.parseObjectToMongoObjectForCreate(className, object, schema);
        object = object = this.transformDateObject(object);

        return this._adaptiveCollection(className).ensureUniqueness(object)
            .then(count => {
                if (count === 0) {
                    return this._adaptiveCollection(className).insertOne(object);
                } else {
                    throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'A duplicate value for a field with unique values was provided');
                }
            })
            .catch(
                error => { throw error }
            );
    }