How to use the parse-server/lib/Adapters/Storage/Mongo/MongoTransform.transformWhere 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
find(className, schema = {}, query = {}, options : Options = {}) : Promise {
        let { skip, limit, sort, keys } = options;
        schema = Transform.convertParseSchemaToMongoSchema(schema);
        query = this.transformDateObject(query);
        query = Transform.transformWhere(className, query, schema);
        query = this.transformDateObject(query);
        sort = _.mapKeys(sort, (value, fieldName) => Transform.transformKey(className, fieldName, schema));
        keys = _.reduce(keys, (memo, key) => {
            memo[Transform.transformKey(className, key, schema)] = 1;
            return memo;
        }, {});
        
        return this._adaptiveCollection(className).find(query, { skip, limit, sort, keys})
            .then(
                objects => objects.map(object => Transform.transformToParseObject(className, object, schema))
            );
    }
github benishak / parse-server-dynamodb-adapter / src / Adapter.ts View on Github external
findOneAndUpdate(className, schema, query, update, upsert = false) : Promise {
        update = this.transformDateObject(update);
        schema = Transform.convertParseSchemaToMongoSchema(schema);
        update = Transform.transformUpdate(className, update, schema);
        update = this.transformDateObject(update);
        query = this.transformDateObject(query);
        query = Transform.transformWhere(className, query, schema);
        query = this.transformDateObject(query);

        return this._adaptiveCollection(className).ensureUniqueness(update['$set'])
            .then(count => {
                if (count === 0) {
                    return this._adaptiveCollection(className).updateOne(query, update, upsert);
                } else {
                    throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'A duplicate value for a field with unique values was provided');
                }
            })
            .then(result => Transform.transformToParseObject(className, result.value, schema))
            .catch(
                error => { throw error }
            )
    }
github benishak / parse-server-dynamodb-adapter / src / Adapter.ts View on Github external
count(className, schema, query) : Promise {
        schema = Transform.convertParseSchemaToMongoSchema(schema);
        query = this.transformDateObject(query);
        query = Transform.transformWhere(className, query, schema);
        query = this.transformDateObject(query);

        return this._adaptiveCollection(className).count(query);
    }
github benishak / parse-server-dynamodb-adapter / src / Adapter.ts View on Github external
deleteObjectsByQuery(className, schema, query) : Promise {
        schema = Transform.convertParseSchemaToMongoSchema(schema);
        query = this.transformDateObject(query);
        query = Transform.transformWhere(className, query, schema);
        query = this.transformDateObject(query);

        return this._adaptiveCollection(className).deleteMany(query)
            .then(
                result => {
                    if (result.n === 0) {
                        throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Object not found.');
                    }
                    return Promise.resolve();
                }
            )
            .catch(
                error => { throw error }
            );
    }
github benishak / parse-server-dynamodb-adapter / src / Adapter.ts View on Github external
updateObjectsByQuery(className, schema, query, update) : Promise {
        update = this.transformDateObject(update);
        schema = Transform.convertParseSchemaToMongoSchema(schema);
        update = Transform.transformUpdate(className, update, schema);
        update = this.transformDateObject(update);
        query = this.transformDateObject(query);
        query = Transform.transformWhere(className, query, schema);
        query = this.transformDateObject(query);

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