Git Product home page Git Product logo

ace-autocompleter's Introduction

mongodb-ace-autocompleter

Provides MongoDB custom ACE Editor auto-completers

Usage

Aggregation Pipelines

Provides completions within the context of an individual aggregation pipeline stage:

import ace from 'brace';
import { StageAutoCompleter } from 'mongodb-ace-autocompleter';

// Get the basic text completer from Ace for fallback suggestions.
const tools = ace.acequire('ace/ext/language_tools');
const textCompleter = tools.textCompleter;

// For auto completion of agg pipeline stages, pass the server version,
// the text completer, the processed schema fields, and the stage operator.
const stageAutoCompleter = new StageAutoCompleter(
  '3.6.0',
  textCompleter,
  [{
    name: 'name',
    value: 'name',
    score: 1,
    meta: 'field',
    version: '0.0.0'
  }],
  '$match'
);
tools.setCompleters([ stageAutoCompleter ]);

Queries

Provides completions within the context of a find(query):

import ace from 'brace';
import { QueryAutoCompleter } from 'mongodb-ace-autocompleter';

// Get the basic text completer from Ace for fallback suggestions.
const tools = ace.acequire('ace/ext/language_tools');
const textCompleter = tools.textCompleter;

// For auto completion of queries, pass the server version,
// the text completer, and the processed schema fields
const queryAutoCompleter = new QueryAutoCompleter(
  '3.6.0',
  textCompleter,
  [{
    name: 'name',
    value: 'name',
    score: 1,
    meta: 'field',
    version: '0.0.0'
  }]
);
tools.setCompleters([ queryAutoCompleter ]);

Related

Misc

Utility function to convert from the fields returned from the field store to the Ace friendly format. (Can be done in a reducer in the app).

const process = (fields) => {
  return Object.keys(fields).map((key) => {
    const field = key.indexOf('.') > -1 ? `"${key}"` : key;
    return {
      name: key,
      value: field,
      score: 1,
      meta: 'field',
      version: '0.0.0'
    };
  });
};

License

Apache 2.0

ace-autocompleter's People

Contributors

addaleax avatar alenakhineika avatar anemy avatar dependabot-preview[bot] avatar durran avatar imlucas avatar lrlna avatar mcasimir avatar mmarcon avatar sampoonachot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.