mongo-to-parse
v2.0.41
Published
MongoToParse transform mongo find query to parse-server find query.
Downloads
339
Readme
MongoToParse
MongoToParse transform mongo find query to parse-server find query.
Getting Started
import { MongoToParseQuery } from 'mongo-to-parse';
...
const mongoToParseQuery = new MongoToParseQuery();
const result = await new MongoToParseQuery().find(mongoToParseQuery.parseTable('TableName'), { where: { rank: 1 }, option: { useMasterKey: true } } };
Supported mongo operands
- $and
- $or
- $gt
- $gte
- $lt
- $lte
- $regex
- $exists
- $in
- $eq
- $nin
- $ne
- $all
additional operands not present in mongo find query.
- $endsWith
- $startsWith
Example
const query = new Parse.Query(TestTable); query.equalTo('total', 4); await query.find();
The above parse query is equivalent to mongo query given below
await mongoToParseQuery.find(TestTable, { where: { total: 4 } });
const query = new Parse.Query(TestTable); query.greatherThan('total', 4); query.lessThan('total', 40); await query.find();
The above parse query is equivalent to mongo query given below
await mongoToParseQuery.find(TestTable, { where: { total: { $gt: 4, $lt: 40 } } });
const query1 = new Parse.Query(TestTable); query1.equalTo('rank', 3); const query2 = new Parse.Query(TestTable); query2.equalTo('total', 2); const query = Parse.Query.and(query1, query2); query.ascending('rank'); await query.find();
The above parse query is equivalent to mongo query given below
await mongoToParseQuery.find(TestTable, { where: { $and: [{ rank: 3 }, { total: 2 }] }, ascending: 'rank' });