Uploaded image for project: 'VS Code Extension'
  1. VS Code Extension
  2. VSCODE-138

Quick index creation

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.2.0
    • Component/s: None
    • Labels:
      None
    • Story Points:
      5
    • Documentation Changes:
      Needed
    • Documentation Changes Summary:
      Hide
      See animated GIF here: https://github.com/mongodb-js/vscode/pull/161.

      Essentially, we added a button to create a playground with a template to create an index.
      Show
      See animated GIF here: https://github.com/mongodb-js/vscode/pull/161 . Essentially, we added a button to create a playground with a template to create an index.
    • Sprint:
      Iteration Jackfruit, Iteration Kiwi

      Description

      User Story

      As a user,
      I want a quick way to create indexes for a collection,
      So that I can easily add an index when I feel it's missing without manually creating a playground and having to remember the right command.

      Acceptance criteria

      • Next to Indexes, we show an entry point to create an index with a playground
      • When I click on the entry point, we open a new playground file with a template for index creation and pointers to the documentation
      • Field autocomplete works for creating index method

      Telemetry (tracking plan)

      • Added Treeview Action Clicked with action=createIndex event to tracking plan

      Playground template

      // MongoDB Playground
      // Use Ctrl+Space inside a snippet or a string literal to trigger completions.
       
      // The current database to use.
      use('CURRENT_DATABASE');
       
      // Search for documents in the current collection.
      db.getCollection('CURRENT_COLLECTION')
        .createIndex(
          {
            /*
             * Keys
             * 
             * Normal index 
             * fieldA:  1, //ascending
             * fieldB: -1  //descending
             * 
             * Wildcard index
             * '$**': 1, //wildcard index on all fields and subfields in a document
             * 'path.to.field.$**': 1 //wildcard index on a specific field and its subpaths
             * 
             * Text index
             * fieldA: 'text',
             * fieldB: 'text'
             * 
             * Geospatial Index
             * locationField: '2dsphere'
             * 
             * Hashed Index
             * fieldA: 'hashed'
             */
          },
          {
            /*
             * Options (https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#options-for-all-index-types)
             *
             * background: true, //ignored in 4.2+
             * unique: false,
             * name: 'some name',
             * partialFilterExpression: {},
             * sparse: false,
             * expireAfterSeconds: TTL,
             * collation: {}
             */
          }
        );
      

        Attachments

        There are no Sub-Tasks for this issue.

          Activity

            People

            Assignee:
            rhys.howell Rhys Howell
            Reporter:
            massimiliano.marcon Massimiliano Marcon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: