UNPKG

contexture-mongo

Version:
1 lines 3.7 kB
[{"filePath":"/home/circleci/project/src/example-types/date.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/example-types/default.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/example-types/exists.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/example-types/facet.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/example-types/mongoId.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/example-types/number.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/example-types/results.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/example-types/text.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/src/index.js","messages":[{"ruleId":"no-unused-vars","severity":1,"message":"'_' is assigned a value but never used.","line":1,"column":5,"nodeType":"Identifier","source":"var _ = require('lodash/fp')","endLine":1,"endColumn":6}],"errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"var _ = require('lodash/fp')\nvar Promise = require('bluebird')\n\n// Basic function to encapsulate everything needed to run a request - tiny wrapper over raw mongo syntax\nvar mongoDSL = (client, dsl) => {\n // if (!_.get(`collections.${dsl.collection}`, client))\n // console.log('missing collection', await client.collections())\n // throw `Collection [${dsl.collection}] does not exist in the client's db!`\n var Collection = client.collection(dsl.collection)\n // if (dsl.resultOptions)\n // return Collection.find(dsl.criteria, dsl.resultOptions)\n // if (dsl.count)\n // return Collection.count(dsl.criteria)\n if (dsl.aggs) return Collection.aggregate(dsl.aggs).toArray()\n}\n\nvar MongoProvider = config => ({\n groupCombinator: (group, filters) => ({\n [`$${group.join === 'not' ? 'nor' : group.join}`]: filters,\n }),\n types: config.types,\n runSearch(options, context, schema, filters, aggs) {\n var client = config.getClient()\n\n var request = {\n // criteria: filters,\n collection: schema.mongo.collection,\n aggs: [\n {\n $match: filters || {},\n },\n ...aggs,\n ],\n }\n\n // Log Request\n context._meta.requests.push(request)\n\n var result = Promise.resolve(mongoDSL(client, request))\n return result.tap(results => {\n // Log response\n request.response = results\n })\n },\n})\n\nmodule.exports = MongoProvider\n"},{"filePath":"/home/circleci/project/test/example-types/date.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/test/example-types/mongoId.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/test/example-types/results.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"/home/circleci/project/test/example-types/text.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}]