How to use mongodb-query-parser - 5 common examples

To help you get started, we’ve selected a few mongodb-query-parser 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 mongo-express / mongo-express / lib / bson.js View on Github external
exports.toString = function (doc) {
  return parser.toJSString(doc, '    ');
};
github mongodb-js / compass-aggregations / src / modules / import-pipeline.js View on Github external
return js.map((stage) => {
      return createStage(
        Object.keys(stage)[0],
        toShellString(Object.values(stage)[0], INDENT),
        null
      );
    });
  } catch (e) {
github mongodb-js / compass-aggregations / src / modules / stage.js View on Github external
export default function generateStage(state) {
  if (!state.isEnabled || !state.stageOperator || state.stage === '') {
    return {};
  }
  const stage = {};
  try {
    const decommented = decomment(state.stage);
    parse(`{${state.stageOperator}: ${decommented}}`);
    stage[state.stageOperator] = parser(decommented);
  } catch (e) {
    state.syntaxError = e.message;
    state.isValid = false;
    state.previewDocuments = [];
    return {};
  }
  state.isValid = true;
  state.syntaxError = null;
  return stage;
}
github mongodb-js / compass-aggregations / src / modules / collation.js View on Github external
export const collationChanged = (collation) => {
  return {
    type: COLLATION_CHANGED,
    collation: queryParser.isCollationValid(collation)
  };
};
github mongodb-js / compass-aggregations / src / modules / import-pipeline.js View on Github external
export const createPipeline = (text) => {
  try {
    const jsText = transpiler[SHELL][JS].compile(text);
    const js = parseFilter(jsText);
    return js.map((stage) => {
      return createStage(
        Object.keys(stage)[0],
        toShellString(Object.values(stage)[0], INDENT),
        null
      );
    });
  } catch (e) {
    return [ createStage(null, '', e.message) ];
  }
};

mongodb-query-parser

Parse MongoDB queries

Apache-2.0
Latest version published 1 month ago

Package Health Score

84 / 100
Full package analysis