Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(mongodb): use C3 token candidates from explicit grammar rules for autocomplete (#19186)

h3n4l6eaa5a659b96
diff --git a/backend/plugin/parser/mongodb/completion.go b/backend/plugin/parser/mongodb/completion.go
index 401650fad4..d1b05a1472 100644
--- a/backend/plugin/parser/mongodb/completion.go
+++ b/backend/plugin/parser/mongodb/completion.go
@@ -47,10 +47,7 @@ func newIgnoredTokens() map[int]bool {
func newPreferredRules() map[int]bool {
return map[int]bool{
- parser.MongoShellParserRULE_dbStatement: true,
parser.MongoShellParserRULE_collectionAccess: true,
- parser.MongoShellParserRULE_methodCall: true,
- parser.MongoShellParserRULE_methodChain: true,
}
}
@@ -124,169 +121,20 @@ func NewCompleter(ctx context.Context, cCtx base.CompletionContext, statement st
}
}
-// completionContext represents the detected context for completion.
-type completionContext int
-
-const (
- contextUnknown completionContext = iota
- contextAfterDBDot // After "db."
- contextAfterDBDotPartial // After "db." with partial identifier (e.g., "db.us")
- contextAfterDBBracket // After "db[" - need to insert "name"]
- contextAfterDBBracketQuote // After "db["" or "db["x" - need to insert name"]
- contextAfterCollectionDot // After "db.collection."
- contextAfterMethodCall // After "db.collection.method()." - cursor methods only
-)
-
-// detectCompletionContext analyzes the token stream to determine completion context.
-func (c *Completer) detectCompletionContext() completionContext {
- // Save current position and restore after analysis
+// previousNonDotToken returns the token type of the previous non-DOT token,
+// skipping hidden tokens. Used to determine if the caret follows a method
+// call (RPAREN) or a collection access (identifier/RBRACKET).
+func (c *Completer) previousNonDotToken() int {
c.scanner.Push()
defer c.scanner.PopAndRestore()
- // Collect tokens backwards from caret position
- var tokens []int
for c.scanner.Backward(true) {
- tokenType := c.scanner.GetTokenType()
- if tokenType == antlr.TokenEOF || tokenType == parser.MongoShellLexerSEMI {
- break
- }
- tokens = append([]int{tokenType}, tokens...)
- if len(tokens) > 30 {
- break
- }
- }
-
- if len(tokens) < 2 {
- return contextUnknown
- }
-
- // Find DB token
- dbIndex := -1
- for i, t := range tokens {
- if t == parser.MongoShellLexerDB {
- dbIndex = i
- break
+ t := c.scanner.GetTokenType()
+ if t != parser.MongoShellLexerDOT {
+ return t
}
}
-
- if dbIndex < 0 {
- return contextUnknown
- }
-
- tokensAfterDB := tokens[dbIndex+1:]
- if len(tokensAfterDB) == 0 {
- return contextUnknown
- }
-
- lastToken := tokens[len(tokens)-1]
-
- // Check if we're in an incomplete bracket access: db[ or db["
- // Pattern: DB LBRACKET (without RBRACKET yet)
- if tokensAfterDB[0] == parser.MongoShellLexerLBRACKET {
- // Check if the bracket is closed
- hasClosingBracket := false
- hasOpenQuote := false
- for _, t := range tokensAfterDB {
- if t == parser.MongoShellLexerRBRACKET {
- hasClosingBracket = true
- break
- }
- // Check for string token (user started typing "...")
- if t == parser.MongoShellLexerDOUBLE_QUOTED_STRING || t == parser.MongoShellLexerSINGLE_QUOTED_STRING {
- hasOpenQuote = true
- }
- }
- if !hasClosingBracket {
- // Still typing inside bracket
- if hasOpenQuote {
- // db["x - has quote, just need name"]
- return contextAfterDBBracketQuote
- }
- // db[ - no quote yet, need "name"]
- return contextAfterDBBracket
- }
- // Bracket is closed, continue to analyze what comes after
- }
-
- // Count collection accesses (either db.coll or db["coll"])
- // and method calls to determine context
- collectionAccessCount := 0
- hasMethodCall := false
-
- // State machine to track: db.coll or db["coll"] patterns
- // Note: We don't count the last token if it's a partial identifier (still being typed)
- i := 0
- for i < len(tokensAfterDB) {
- t := tokensAfterDB[i]
- isLastToken := (i == len(tokensAfterDB)-1)
-
- switch t {
- case parser.MongoShellLexerDOT:
- // After a DOT, check what follows
- if i+1 < len(tokensAfterDB) {
- next := tokensAfterDB[i+1]
- nextIsLast := (i+1 == len(tokensAfterDB)-1)
- // Check if it's an identifier (collection name or method name)
- // But don't count if it's the last token (partial identifier being typed)
- if isIdentifierToken(next) && !nextIsLast {
- collectionAccessCount++
- }
- }
- // If DOT is the last token, we're at db. or db.coll. - don't count yet
- i++
- case parser.MongoShellLexerLBRACKET:
- // Skip bracket access: ["..."]
- for i < len(tokensAfterDB) && tokensAfterDB[i] != parser.MongoShellLexerRBRACKET {
- i++
- }
- if i < len(tokensAfterDB) && !isLastToken {
- // Found RBRACKET, this counts as a collection access
- collectionAccessCount++
- }
- i++
- case parser.MongoShellLexerRPAREN:
- // Check if this is followed by DOT (method chaining)
- if i+1 < len(tokensAfterDB) && tokensAfterDB[i+1] == parser.MongoShellLexerDOT {
- hasMethodCall = true
- }
- i++
- default:
- i++
- }
- }
-
- // Determine context based on last token and counts
- // Case 1: db. (DOT right after db, no collection access yet)
- if lastToken == parser.MongoShellLexerDOT && collectionAccessCount == 0 {
- return contextAfterDBDot
- }
-
- // Case 2: db.u (partial identifier after db.)
- if collectionAccessCount == 0 && isIdentifierToken(lastToken) {
- return contextAfterDBDotPartial
- }
-
- // Case 3: db.coll. or db["coll"]. (one collection access, ends with DOT)
- if lastToken == parser.MongoShellLexerDOT && collectionAccessCount == 1 && !hasMethodCall {
- return contextAfterCollectionDot
- }
-
- // Case 4: db.coll.find(). or db["coll"].find(). (has method call)
- if lastToken == parser.MongoShellLexerDOT && hasMethodCall {
- return contextAfterMethodCall
- }
-
- return contextUnknown
-}
-
-// isIdentifierToken returns true if the token is an identifier or a method keyword.
-func isIdentifierToken(token int) bool {
- // IDENTIFIER token or any method keyword token
- if token == parser.MongoShellLexerIDENTIFIER {
- return true
- }
- // Method keywords are also valid identifiers in collection position
- return isMethodToken(token)
+ return antlr.TokenEOF
}
// listCollections returns collection names from the default database.
@@ -335,113 +183,45 @@ func (c *Completer) complete() ([]base.Candidate, error) {
}
// convertCandidates converts ANTLR C3 candidates to completion candidates.
+// It uses C3 preferred rules to determine context:
+// - RULE_collectionAccess: after "db." or "db[" — suggest database methods + collections
+//
+// C3 tokens are used in all positions. At the database level (db.|), the collectionAccess
+// preferred rule prevents C3 from exploring into methodChain, so only legitimate db method
+// tokens appear. At collection/cursor level, C3 tokens provide the correct method candidates.
func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) ([]base.Candidate, error) {
var result []base.Candidate
- // Add keyword/method candidates from tokens
- // ANTLR C3 returns token IDs that are valid at the caret position
- for token := range candidates.Tokens {
- if token < 0 || token >= len(c.lexer.LiteralNames) {
- continue
- }
-
- // Get the literal name (e.g., "'find'", "'aggregate'")
- literal := c.lexer.LiteralNames[token]
- if literal == "" {
- continue
- }
-
- // Remove quotes from literal name
- text := strings.Trim(literal, "'")
- if text == "" {
- continue
- }
+ _, hasCollectionAccess := candidates.Rules[parser.MongoShellParserRULE_collectionAccess]
- // Determine candidate type based on token
- candidateType := c.getTokenCandidateType(token)
- if candidateType == base.CandidateTypeFunction {
- // Methods should have () suffix
- result = append(result, base.Candidate{
- Type: base.CandidateTypeFunction,
- Text: text + "()",
- })
- } else {
- result = append(result, base.Candidate{
- Type: candidateType,
- Text: text,
- })
- }
- }
+ // Convert C3 token candidates to function candidates.
+ // All tokens at any position are methods, so treat them as functions with "()" suffix.
+ result = append(result, c.getTokenCandidates(candidates)...)
- // Detect context from token stream to determine what suggestions to add
- context := c.detectCompletionContext()
-
- // Add candidates based on detected context
- // ANTLR C3 may not return all tokens due to grammar complexity,
- // so we inject methods based on the detected context.
- switch context {
- case contextAfterDBDot:
- // After "db." - suggest database methods and collections with bracket notation for special chars
- result = append(result, c.getDatabaseMethodCandidates()...)
- for _, collection := range c.listCollections() {
- // For collections with special characters, use bracket notation
- if needsBracketNotation(collection) {
- result = append(result, base.Candidate{
- Type: base.CandidateTypeTable,
- Text: formatBracketNotation(collection),
- })
- } else {
+ if hasCollectionAccess {
+ // At db.| or db[ position — also add collection candidates from metadata.
+ prevToken := c.previousNonDotToken()
+ switch prevToken {
+ case parser.MongoShellLexerLBRACKET:
+ for _, collection := range c.listCollections() {
result = append(result, base.Candidate{
Type: base.CandidateTypeTable,
- Text: collection,
+ Text: formatBracketContent(collection),
})
}
- }
- case contextAfterDBDotPartial:
- // After "db.us" - user is typing identifier, suggest plain collection names for filtering
- result = append(result, c.getDatabaseMethodCandidates()...)
- for _, collection := range c.listCollections() {
- result = append(result, base.Candidate{
- Type: base.CandidateTypeTable,
- Text: collection,
- })
- }
- case contextAfterDBBracket:
- // After "db[" - need to insert "name"]
- for _, collection := range c.listCollections() {
- result = append(result, base.Candidate{
- Type: base.CandidateTypeTable,
- Text: formatBracketContent(collection),
- })
- }
- case contextAfterDBBracketQuote:
- // After "db["" or "db["x" - just need name (quote already exists)
- for _, collection := range c.listCollections() {
- result = append(result, base.Candidate{
- Type: base.CandidateTypeTable,
- Text: collection,
- })
- }
- case contextAfterCollectionDot:
- // After "db.collection." - suggest collection and cursor methods
- result = append(result, c.getCollectionMethodCandidates()...)
- case contextAfterMethodCall:
- // After "db.collection.method()." - suggest cursor methods only
- result = append(result, c.getCursorMethodCandidates()...)
- default:
- // For other contexts, use the preferred rules from C3
- for rule := range candidates.Rules {
- switch rule {
- case parser.MongoShellParserRULE_collectionAccess:
- // Suggest collections
- for _, collection := range c.listCollections() {
+ default:
+ for _, collection := range c.listCollections() {
+ if needsBracketNotation(collection) {
+ result = append(result, base.Candidate{
+ Type: base.CandidateTypeTable,
+ Text: formatBracketNotation(collection),
+ })
+ } else {
result = append(result, base.Candidate{
Type: base.CandidateTypeTable,
Text: collection,
})
}
- default:
- // Ignore other rules
}
}
}
@@ -468,289 +248,29 @@ func (c *Completer) convertCandidates(candidates *base.CandidatesCollection) ([]
}), nil
}
-// getTokenCandidateType returns the candidate type for a token.
-func (*Completer) getTokenCandidateType(token int) base.CandidateType {
- if isMethodToken(token) {
- return base.CandidateTypeFunction
- }
- return base.CandidateTypeKeyword
-}
-
-// getDatabaseMethodCandidates returns candidates for database methods (after "db.").
-func (*Completer) getDatabaseMethodCandidates() []base.Candidate {
- methods := []string{
- "getCollectionNames",
- "getCollectionInfos",
- "createCollection",
- "dropDatabase",
- "stats",
- "serverStatus",
- "serverBuildInfo",
- "version",
- "hostInfo",
- "listCommands",
- "runCommand",
- "adminCommand",
- "getName",
- "getMongo",
- "getSiblingDB",
- }
+// getTokenCandidates converts C3 token candidates to function candidates.
+func (c *Completer) getTokenCandidates(candidates *base.CandidatesCollection) []base.Candidate {
var result []base.Candidate
- for _, m := range methods {
- result = append(result, base.Candidate{
- Type: base.CandidateTypeFunction,
- Text: m + "()",
- })
- }
- return result
-}
-
-// getCollectionMethodCandidates returns candidates for collection methods (after "db.collection.").
-func (*Completer) getCollectionMethodCandidates() []base.Candidate {
- methods := []string{
- // Query methods
- "find",
- "findOne",
- "countDocuments",
- "estimatedDocumentCount",
- "distinct",
- "aggregate",
- "getIndexes",
- // Write methods
- "insertOne",
- "insertMany",
- "updateOne",
- "updateMany",
- "deleteOne",
- "deleteMany",
- "replaceOne",
- "findOneAndUpdate",
- "findOneAndReplace",
- "findOneAndDelete",
- // Index methods
- "createIndex",
- "createIndexes",
- "dropIndex",
- "dropIndexes",
- // Collection management
- "drop",
- "renameCollection",
- "stats",
- "storageSize",
- "totalIndexSize",
- "totalSize",
- "dataSize",
- "isCapped",
- "validate",
- "latencyStats",
- "watch",
- // Bulk operations
- "initializeOrderedBulkOp",
- "initializeUnorderedBulkOp",
- // Cursor methods (can be chained after find)
- "sort",
- "limit",
- "skip",
- "projection",
- "project",
- "count",
- "batchSize",
- "close",
- "collation",
- "comment",
- "explain",
- "forEach",
- "hasNext",
- "hint",
- "isClosed",
- "isExhausted",
- "itcount",
- "map",
- "max",
- "maxAwaitTimeMS",
- "maxTimeMS",
- "min",
- "next",
- "noCursorTimeout",
- "objsLeftInBatch",
- "pretty",
- "readConcern",
- "readPref",
- "returnKey",
- "showRecordId",
- "size",
- "tailable",
- "toArray",
- "tryNext",
- "allowDiskUse",
- "addOption",
- }
- var result []base.Candidate
- for _, m := range methods {
- result = append(result, base.Candidate{
- Type: base.CandidateTypeFunction,
- Text: m + "()",
- })
- }
- return result
-}
-
-// getCursorMethodCandidates returns candidates for cursor methods only (after method call like "find().").
-func (*Completer) getCursorMethodCandidates() []base.Candidate {
- methods := []string{
- // Cursor methods that can be chained
- "sort",
- "limit",
- "skip",
- "projection",
- "project",
- "count",
- "batchSize",
- "close",
- "collation",
- "comment",
- "explain",
- "forEach",
- "hasNext",
- "hint",
- "isClosed",
- "isExhausted",
- "itcount",
- "map",
- "max",
- "maxAwaitTimeMS",
- "maxTimeMS",
- "min",
- "next",
- "noCursorTimeout",
- "objsLeftInBatch",
- "pretty",
- "readConcern",
- "readPref",
- "returnKey",
- "showRecordId",
- "size",
- "tailable",
- "toArray",
- "tryNext",
- "allowDiskUse",
- "addOption",
- }
- var result []base.Candidate
- for _, m := range methods {
+ for token := range candidates.Tokens {
+ if token < 0 || token >= len(c.lexer.LiteralNames) {
+ continue
+ }
+ literal := c.lexer.LiteralNames[token]
+ if literal == "" {
+ continue
+ }
+ text := strings.Trim(literal, "'")
+ if text == "" {
+ continue
+ }
result = append(result, base.Candidate{
Type: base.CandidateTypeFunction,
- Text: m + "()",
+ Text: text + "()",
})
}
return result
}
-// isMethodToken returns true if the token represents a method.
-func isMethodToken(token int) bool {
- switch token {
- // Collection methods
- case parser.MongoShellLexerFIND,
- parser.MongoShellLexerFIND_ONE,
- parser.MongoShellLexerCOUNT_DOCUMENTS,
- parser.MongoShellLexerESTIMATED_DOCUMENT_COUNT,
- parser.MongoShellLexerDISTINCT,
- parser.MongoShellLexerAGGREGATE,
- parser.MongoShellLexerGET_INDEXES,
- parser.MongoShellLexerINSERT_ONE,
- parser.MongoShellLexerINSERT_MANY,
- parser.MongoShellLexerUPDATE_ONE,
- parser.MongoShellLexerUPDATE_MANY,
- parser.MongoShellLexerDELETE_ONE,
- parser.MongoShellLexerDELETE_MANY,
- parser.MongoShellLexerREPLACE_ONE,
- parser.MongoShellLexerFIND_ONE_AND_UPDATE,
- parser.MongoShellLexerFIND_ONE_AND_REPLACE,
- parser.MongoShellLexerFIND_ONE_AND_DELETE,
- parser.MongoShellLexerCREATE_INDEX,
- parser.MongoShellLexerCREATE_INDEXES,
- parser.MongoShellLexerDROP_INDEX,
- parser.MongoShellLexerDROP_INDEXES,
- parser.MongoShellLexerDROP,
- parser.MongoShellLexerRENAME_COLLECTION,
- parser.MongoShellLexerSTATS,
- parser.MongoShellLexerSTORAGE_SIZE,
- parser.MongoShellLexerTOTAL_INDEX_SIZE,
- parser.MongoShellLexerTOTAL_SIZE,
- parser.MongoShellLexerDATA_SIZE,
- parser.MongoShellLexerIS_CAPPED,
- parser.MongoShellLexerVALIDATE,
- parser.MongoShellLexerLATENCY_STATS,
- parser.MongoShellLexerWATCH,
- // Database methods
- parser.MongoShellLexerGET_COLLECTION,
- parser.MongoShellLexerGET_COLLECTION_NAMES,
- parser.MongoShellLexerGET_COLLECTION_INFOS,
- parser.MongoShellLexerCREATE_COLLECTION,
- parser.MongoShellLexerDROP_DATABASE,
- parser.MongoShellLexerHOST_INFO,
- parser.MongoShellLexerLIST_COMMANDS,
- parser.MongoShellLexerSERVER_BUILD_INFO,
- parser.MongoShellLexerSERVER_STATUS,
- parser.MongoShellLexerVERSION,
- parser.MongoShellLexerRUN_COMMAND,
- parser.MongoShellLexerADMIN_COMMAND,
- parser.MongoShellLexerGET_NAME,
- parser.MongoShellLexerGET_MONGO,
- parser.MongoShellLexerGET_SIBLING_DB,
- parser.MongoShellLexerGET_DB,
- parser.MongoShellLexerGET_DB_NAMES,
- // Cursor methods
- parser.MongoShellLexerSORT,
- parser.MongoShellLexerLIMIT,
- parser.MongoShellLexerSKIP_,
- parser.MongoShellLexerPROJECTION,
- parser.MongoShellLexerPROJECT,
- parser.MongoShellLexerCOUNT,
- parser.MongoShellLexerBATCH_SIZE,
- parser.MongoShellLexerCLOSE,
- parser.MongoShellLexerCOLLATION,
- parser.MongoShellLexerCOMMENT,
- parser.MongoShellLexerEXPLAIN,
- parser.MongoShellLexerFOR_EACH,
- parser.MongoShellLexerHAS_NEXT,
- parser.MongoShellLexerHINT,
- parser.MongoShellLexerIS_CLOSED,
- parser.MongoShellLexerIS_EXHAUSTED,
- parser.MongoShellLexerIT_COUNT,
- parser.MongoShellLexerMAP,
- parser.MongoShellLexerMAX,
- parser.MongoShellLexerMAX_AWAIT_TIME_MS,
- parser.MongoShellLexerMAX_TIME_MS,
- parser.MongoShellLexerMIN,
- parser.MongoShellLexerNEXT,
- parser.MongoShellLexerNO_CURSOR_TIMEOUT,
- parser.MongoShellLexerOBJS_LEFT_IN_BATCH,
- parser.MongoShellLexerPRETTY,
- parser.MongoShellLexerREAD_CONCERN,
- parser.MongoShellLexerREAD_PREF,
- parser.MongoShellLexerRETURN_KEY,
- parser.MongoShellLexerSHOW_RECORD_ID,
- parser.MongoShellLexerSIZE,
- parser.MongoShellLexerTAILABLE,
- parser.MongoShellLexerTO_ARRAY,
- parser.MongoShellLexerTRY_NEXT,
- parser.MongoShellLexerALLOW_DISK_USE,
- parser.MongoShellLexerADD_OPTION,
- // Bulk methods
- parser.MongoShellLexerINITIALIZE_ORDERED_BULK_OP,
- parser.MongoShellLexerINITIALIZE_UNORDERED_BULK_OP,
- parser.MongoShellLexerEXECUTE,
- parser.MongoShellLexerGET_OPERATIONS,
- parser.MongoShellLexerTO_STRING,
- parser.MongoShellLexerINSERT,
- parser.MongoShellLexerREMOVE:
- return true
- default:
- return false
- }
-}
-
// needsBracketNotation returns true if the collection name contains special characters
// that require bracket notation (db["name"]) instead of dot notation (db.name).
func needsBracketNotation(name string) bool {
diff --git a/backend/plugin/parser/mongodb/completion_test.go b/backend/plugin/parser/mongodb/completion_test.go
index f0de742238..93a78150c8 100644
--- a/backend/plugin/parser/mongodb/completion_test.go
+++ b/backend/plugin/parser/mongodb/completion_test.go
@@ -40,12 +40,12 @@ func TestCompletion(t *testing.T) {
a.NoError(yaml.Unmarshal(byteValue, &tests))
for i, tc := range tests {
- text, caretOffset := catchCaret(tc.Input)
+ text, caretLine, caretOffset := catchCaret(tc.Input)
result, err := base.Completion(context.Background(), storepb.Engine_MONGODB, base.CompletionContext{
Scene: base.SceneTypeAll,
DefaultDatabase: "test",
Metadata: getMetadataForTest,
- }, text, 1, caretOffset)
+ }, text, caretLine, caretOffset)
a.NoError(err)
// Sort results for consistent comparison
@@ -100,11 +100,23 @@ func getMetadataForTest(_ context.Context, _, databaseName string) (string, *mod
}, nil, nil, storepb.Engine_MONGODB, true /* isObjectCaseSensitive */), nil
}
-func catchCaret(s string) (string, int) {
+// catchCaret finds the | marker in the input and returns:
+// - the text with the marker removed
+// - the 1-based line number where the marker was
+// - the 0-based column offset on that line
+func catchCaret(s string) (string, int, int) {
+ line := 1
+ col := 0
for i, c := range s {
if c == '|' {
- return s[:i] + s[i+1:], i
+ return s[:i] + s[i+1:], line, col
+ }
+ if c == '\n' {
+ line++
+ col = 0
+ } else {
+ col++
}
}
- return s, -1
+ return s, -1, -1
}
diff --git a/backend/plugin/parser/mongodb/query_type.go b/backend/plugin/parser/mongodb/query_type.go
index e54d280a57..aff22c7358 100644
--- a/backend/plugin/parser/mongodb/query_type.go
+++ b/backend/plugin/parser/mongodb/query_type.go
@@ -105,11 +105,6 @@ func (l *queryTypeListener) EnterGetMongo(_ *mongodb.GetMongoContext) {
l.result = base.DML
}
-//nolint:staticcheck // Method name must match ANTLR-generated listener interface.
-func (l *queryTypeListener) EnterDbGenericMethod(_ *mongodb.DbGenericMethodContext) {
- l.result = base.DML
-}
-
// runCommand / adminCommand: classify by argument text.
func (l *queryTypeListener) EnterRunCommand(ctx *mongodb.RunCommandContext) {
@@ -166,31 +161,35 @@ func (l *queryTypeListener) EnterCollectionOperation(ctx *mongodb.CollectionOper
}
func classifyMethodChain(chain mongodb.IMethodChainContext) base.QueryType {
- calls := chain.AllMethodCall()
- if len(calls) == 0 {
- return base.DML
+ // Check if .explain() prefix exists (db.collection.explain().find())
+ if chain.CollectionExplainMethod() != nil {
+ return base.Explain
}
- // Check if .explain() appears anywhere in the chain.
- for _, call := range calls {
- if call.ExplainMethod() != nil {
+ // Check cursor methods for explain().
+ for _, cursor := range chain.AllCursorMethodCall() {
+ if cursor.ExplainMethod() != nil {
return base.Explain
}
}
- // Classify based on the first method call.
- first := calls[0]
- return classifyMethodCall(first)
+ // Classify based on the collection method call.
+ mc := chain.CollectionMethodCall()
+ if mc != nil {
+ return classifyCollectionMethodCall(mc)
+ }
+
+ return base.DML
}
-func classifyMethodCall(mc mongodb.IMethodCallContext) base.QueryType {
+func classifyCollectionMethodCall(mc mongodb.ICollectionMethodCallContext) base.QueryType {
switch {
// Read methods -> Select.
case mc.FindMethod() != nil,
mc.FindOneMethod() != nil,
mc.CountDocumentsMethod() != nil,
mc.EstimatedDocumentCountMethod() != nil,
- mc.CountMethod() != nil,
+ mc.CollectionCountMethod() != nil,
mc.DistinctMethod() != nil:
return base.Select
@@ -208,7 +207,13 @@ func classifyMethodCall(mc mongodb.IMethodCallContext) base.QueryType {
mc.ReplaceOneMethod() != nil,
mc.FindOneAndUpdateMethod() != nil,
mc.FindOneAndReplaceMethod() != nil,
- mc.FindOneAndDeleteMethod() != nil:
+ mc.FindOneAndDeleteMethod() != nil,
+ mc.CollectionInsertMethod() != nil,
+ mc.CollectionRemoveMethod() != nil,
+ mc.UpdateMethod() != nil,
+ mc.BulkWriteMethod() != nil,
+ mc.FindAndModifyMethod() != nil,
+ mc.MapReduceMethod() != nil:
return base.DML
// DDL methods.
@@ -217,7 +222,14 @@ func classifyMethodCall(mc mongodb.IMethodCallContext) base.QueryType {
mc.DropIndexMethod() != nil,
mc.DropIndexesMethod() != nil,
mc.DropMethod() != nil,
- mc.RenameCollectionMethod() != nil:
+ mc.RenameCollectionMethod() != nil,
+ mc.HideIndexMethod() != nil,
+ mc.UnhideIndexMethod() != nil,
+ mc.ReIndexMethod() != nil,
+ mc.CreateSearchIndexMethod() != nil,
+ mc.CreateSearchIndexesMethod() != nil,
+ mc.DropSearchIndexMethod() != nil,
+ mc.UpdateSearchIndexMethod() != nil:
return base.DDL
// Info methods -> SelectInfoSchema.
@@ -229,17 +241,16 @@ func classifyMethodCall(mc mongodb.IMethodCallContext) base.QueryType {
mc.DataSizeMethod() != nil,
mc.IsCappedMethod() != nil,
mc.ValidateMethod() != nil,
- mc.LatencyStatsMethod() != nil:
+ mc.LatencyStatsMethod() != nil,
+ mc.GetShardDistributionMethod() != nil,
+ mc.GetShardVersionMethod() != nil,
+ mc.AnalyzeShardKeyMethod() != nil:
return base.SelectInfoSchema
// Explain.
- case mc.ExplainMethod() != nil:
+ case mc.CollectionExplainMethod() != nil:
return base.Explain
- // Generic/unknown method -> DML.
- case mc.GenericMethod() != nil:
- return base.DML
-
default:
return base.DML
}
diff --git a/backend/plugin/parser/mongodb/query_type_test.go b/backend/plugin/parser/mongodb/query_type_test.go
index e31a159ce0..e2f1e9b340 100644
--- a/backend/plugin/parser/mongodb/query_type_test.go
+++ b/backend/plugin/parser/mongodb/query_type_test.go
@@ -336,12 +336,12 @@ func TestGetQueryType(t *testing.T) {
want: base.DML,
},
- // Parse error with partial AST: parser cannot recover "find" from the
- // incomplete input, so it falls back to the default DML.
+ // Parse error with partial AST: parser recovers enough to identify "find"
+ // from the incomplete input.
{
description: "incomplete find statement",
statement: `db.users.find({`,
- want: base.DML,
+ want: base.Select,
},
// Completely unparseable.
diff --git a/backend/plugin/parser/mongodb/test-data/test_completion.yaml b/backend/plugin/parser/mongodb/test-data/test_completion.yaml
index 6b12ca0b10..d18b1cf79e 100644
--- a/backend/plugin/parser/mongodb/test-data/test_completion.yaml
+++ b/backend/plugin/parser/mongodb/test-data/test_completion.yaml
@@ -5,208 +5,1237 @@
definition: ""
comment: ""
priority: 0
+ - text: aggregate()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: auth()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: changeUserPassword()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: cloneDatabase()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: commandHelp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: copyDatabase()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
- text: createCollection()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dropDatabase()
+ - text: createRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createView()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: currentOp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropAllRoles()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropAllUsers()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropDatabase()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: fsyncLock()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: fsyncUnlock()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getCollectionInfos()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getCollectionNames()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getLogComponents()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getMongo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getName()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getProfilingLevel()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getProfilingStatus()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getRoles()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getSiblingDB()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getUsers()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: grantPrivilegesToRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: grantRolesToRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: grantRolesToUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: hello()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: hostInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: isMaster()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: killOp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: listCommands()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: logout()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printCollectionStats()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printSecondaryReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printShardingStatus()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printSlaveReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: revokePrivilegesFromRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: revokeRolesFromRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: revokeRolesFromUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: rotateCertificates()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: runCommand()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: serverBuildInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: serverStatus()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setLogLevel()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setProfilingLevel()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setSecondaryOk()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setWriteConcern()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: shutdownServer()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: stats()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: updateRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: updateUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: version()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: watch()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: '["my-collection"]'
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: orders
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: users
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+- input: db.u|
+ want:
+ - text: adminCommand()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: aggregate()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: auth()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: changeUserPassword()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: cloneDatabase()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: commandHelp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: copyDatabase()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createCollection()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createView()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: currentOp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropAllRoles()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropAllUsers()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropDatabase()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: fsyncLock()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: fsyncUnlock()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getCollectionInfos()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getCollectionNames()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getLogComponents()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getMongo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getName()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getProfilingLevel()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getProfilingStatus()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getRoles()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getSiblingDB()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getUsers()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: grantPrivilegesToRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: grantRolesToRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: grantRolesToUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: hello()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: hostInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: isMaster()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: killOp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: listCommands()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: logout()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printCollectionStats()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printSecondaryReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printShardingStatus()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: printSlaveReplicationInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: revokePrivilegesFromRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: revokeRolesFromRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: revokeRolesFromUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: rotateCertificates()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: runCommand()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: serverBuildInfo()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: serverStatus()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setLogLevel()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setProfilingLevel()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setSecondaryOk()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: setWriteConcern()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: shutdownServer()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: stats()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: updateRole()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: updateUser()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: version()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: watch()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: '["my-collection"]'
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: orders
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: users
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+- input: db[|
+ want:
+ - text: '"my-collection"]'
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: '"orders"]'
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: '"users"]'
+ type: TABLE
+ definition: ""
+ comment: ""
+ priority: 0
+- input: db.users.|
+ want:
+ - text: aggregate()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: analyzeShardKey()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: bulkWrite()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: compactStructuredEncryptionData()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: configureQueryAnalyzer()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: count()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: countDocuments()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createIndexes()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createSearchIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createSearchIndexes()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dataSize()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: deleteMany()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: deleteOne()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: distinct()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: drop()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropIndexes()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropSearchIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: estimatedDocumentCount()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: explain()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: find()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: findAndModify()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: findOne()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: findOneAndDelete()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: findOneAndReplace()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: findOneAndUpdate()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getIndexes()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getPlanCache()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getShardDistribution()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: getShardVersion()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: hideIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: initializeOrderedBulkOp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: initializeUnorderedBulkOp()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: insert()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: insertMany()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: insertOne()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: isCapped()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: latencyStats()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: mapReduce()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: reIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: remove()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: renameCollection()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: replaceOne()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: stats()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: storageSize()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: totalIndexSize()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: totalSize()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: unhideIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: update()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: updateMany()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: updateOne()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: updateSearchIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: validate()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: watch()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+- input: db["users"].|
+ want:
+ - text: aggregate()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: analyzeShardKey()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: bulkWrite()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: compactStructuredEncryptionData()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: configureQueryAnalyzer()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: count()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: countDocuments()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createIndexes()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createSearchIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: createSearchIndexes()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dataSize()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: deleteMany()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: deleteOne()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: distinct()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: drop()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropIndex()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: dropIndexes()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getCollectionInfos()
+ - text: dropSearchIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getCollectionNames()
+ - text: estimatedDocumentCount()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getMongo()
+ - text: explain()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getName()
+ - text: find()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getSiblingDB()
+ - text: findAndModify()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hostInfo()
+ - text: findOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: listCommands()
+ - text: findOneAndDelete()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: runCommand()
+ - text: findOneAndReplace()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: serverBuildInfo()
+ - text: findOneAndUpdate()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: serverStatus()
+ - text: getIndexes()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: stats()
+ - text: getPlanCache()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: version()
+ - text: getShardDistribution()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: '["my-collection"]'
- type: TABLE
+ - text: getShardVersion()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: orders
- type: TABLE
+ - text: hideIndex()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: users
- type: TABLE
+ - text: initializeOrderedBulkOp()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
-- input: db.u|
- want:
- - text: adminCommand()
+ - text: initializeUnorderedBulkOp()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: createCollection()
+ - text: insert()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dropDatabase()
+ - text: insertMany()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getCollectionInfos()
+ - text: insertOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getCollectionNames()
+ - text: isCapped()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getMongo()
+ - text: latencyStats()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getName()
+ - text: mapReduce()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getSiblingDB()
+ - text: reIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hostInfo()
+ - text: remove()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: listCommands()
+ - text: renameCollection()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: runCommand()
+ - text: replaceOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: serverBuildInfo()
+ - text: stats()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: serverStatus()
+ - text: storageSize()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: stats()
+ - text: totalIndexSize()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: version()
+ - text: totalSize()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: my-collection
- type: TABLE
+ - text: unhideIndex()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: orders
- type: TABLE
+ - text: update()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: users
- type: TABLE
+ - text: updateMany()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
-- input: db[|
- want:
- - text: '"my-collection"]'
- type: TABLE
+ - text: updateOne()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: '"orders"]'
- type: TABLE
+ - text: updateSearchIndex()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: '"users"]'
- type: TABLE
+ - text: validate()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
-- input: db.users.|
- want:
- - text: addOption()
+ - text: watch()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: aggregate()
+- input: db.users.find().|
+ want:
+ - text: addOption()
type: FUNCTION
definition: ""
comment: ""
@@ -241,152 +1270,219 @@
definition: ""
comment: ""
priority: 0
- - text: countDocuments()
+ - text: explain()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: createIndex()
+ - text: forEach()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: createIndexes()
+ - text: hasNext()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dataSize()
+ - text: hint()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: deleteMany()
+ - text: isClosed()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: deleteOne()
+ - text: isExhausted()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: distinct()
+ - text: itcount()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: drop()
+ - text: limit()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dropIndex()
+ - text: map()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dropIndexes()
+ - text: max()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: estimatedDocumentCount()
+ - text: maxAwaitTimeMS()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: explain()
+ - text: maxTimeMS()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: find()
+ - text: min()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOne()
+ - text: next()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOneAndDelete()
+ - text: noCursorTimeout()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOneAndReplace()
+ - text: objsLeftInBatch()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOneAndUpdate()
+ - text: pretty()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: forEach()
+ - text: project()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getIndexes()
+ - text: projection()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hasNext()
+ - text: readConcern()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hint()
+ - text: readPref()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: initializeOrderedBulkOp()
+ - text: returnKey()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: initializeUnorderedBulkOp()
+ - text: showRecordId()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: insertMany()
+ - text: size()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: insertOne()
+ - text: skip()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isCapped()
+ - text: sort()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isClosed()
+ - text: tailable()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isExhausted()
+ - text: toArray()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: itcount()
+ - text: tryNext()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: latencyStats()
+- input: db.users.find().sort().|
+ want:
+ - text: addOption()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: allowDiskUse()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: batchSize()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: close()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: collation()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: comment()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: count()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: explain()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: forEach()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: hasNext()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: hint()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: isClosed()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: isExhausted()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: itcount()
type: FUNCTION
definition: ""
comment: ""
@@ -461,823 +1557,844 @@
definition: ""
comment: ""
priority: 0
- - text: renameCollection()
+ - text: returnKey()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: replaceOne()
+ - text: showRecordId()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: returnKey()
+ - text: size()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: showRecordId()
+ - text: skip()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: size()
+ - text: sort()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: skip()
+ - text: tailable()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: sort()
+ - text: toArray()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: stats()
+ - text: tryNext()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: storageSize()
+- input: db["users"].find().|
+ want:
+ - text: addOption()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: allowDiskUse()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: batchSize()
+ type: FUNCTION
+ definition: ""
+ comment: ""
+ priority: 0
+ - text: close()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: tailable()
+ - text: collation()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: toArray()
+ - text: comment()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: totalIndexSize()
+ - text: count()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: totalSize()
+ - text: explain()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: tryNext()
+ - text: forEach()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: updateMany()
+ - text: hasNext()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: updateOne()
+ - text: hint()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: validate()
+ - text: isClosed()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: watch()
+ - text: isExhausted()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getPlanCache
- type: KEYWORD
+ - text: itcount()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
-- input: db["users"].|
- want:
- - text: addOption()
+ - text: limit()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: aggregate()
+ - text: map()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: allowDiskUse()
+ - text: max()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: batchSize()
+ - text: maxAwaitTimeMS()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: close()
+ - text: maxTimeMS()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: collation()
+ - text: min()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: comment()
+ - text: next()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: count()
+ - text: noCursorTimeout()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: countDocuments()
+ - text: objsLeftInBatch()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: createIndex()
+ - text: pretty()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: createIndexes()
+ - text: project()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dataSize()
+ - text: projection()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: deleteMany()
+ - text: readConcern()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: deleteOne()
+ - text: readPref()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: distinct()
+ - text: returnKey()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: drop()
+ - text: showRecordId()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dropIndex()
+ - text: size()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: dropIndexes()
+ - text: skip()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: estimatedDocumentCount()
+ - text: sort()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: explain()
+ - text: tailable()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: find()
+ - text: toArray()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOne()
+ - text: tryNext()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOneAndDelete()
+- input: |-
+ db.users.find().limit(20)
+ db.users.|
+ want:
+ - text: aggregate()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOneAndReplace()
+ - text: analyzeShardKey()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: findOneAndUpdate()
+ - text: bulkWrite()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: forEach()
+ - text: compactStructuredEncryptionData()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getIndexes()
+ - text: configureQueryAnalyzer()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hasNext()
+ - text: count()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hint()
+ - text: countDocuments()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: initializeOrderedBulkOp()
+ - text: createIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: initializeUnorderedBulkOp()
+ - text: createIndexes()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: insertMany()
+ - text: createSearchIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: insertOne()
+ - text: createSearchIndexes()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isCapped()
+ - text: dataSize()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isClosed()
+ - text: deleteMany()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isExhausted()
+ - text: deleteOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: itcount()
+ - text: distinct()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: latencyStats()
+ - text: drop()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: limit()
+ - text: dropIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: map()
+ - text: dropIndexes()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: max()
+ - text: dropSearchIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: maxAwaitTimeMS()
+ - text: estimatedDocumentCount()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: maxTimeMS()
+ - text: explain()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: min()
+ - text: find()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: next()
+ - text: findAndModify()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: noCursorTimeout()
+ - text: findOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: objsLeftInBatch()
+ - text: findOneAndDelete()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: pretty()
+ - text: findOneAndReplace()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: project()
+ - text: findOneAndUpdate()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: projection()
+ - text: getIndexes()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: readConcern()
+ - text: getPlanCache()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: readPref()
+ - text: getShardDistribution()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: renameCollection()
+ - text: getShardVersion()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: replaceOne()
+ - text: hideIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: returnKey()
+ - text: initializeOrderedBulkOp()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: showRecordId()
+ - text: initializeUnorderedBulkOp()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: size()
+ - text: insert()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: skip()
+ - text: insertMany()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: sort()
+ - text: insertOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: stats()
+ - text: isCapped()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: storageSize()
+ - text: latencyStats()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: tailable()
+ - text: mapReduce()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: toArray()
+ - text: reIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: totalIndexSize()
+ - text: remove()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: totalSize()
+ - text: renameCollection()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: tryNext()
+ - text: replaceOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: updateMany()
+ - text: stats()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: updateOne()
+ - text: storageSize()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: validate()
+ - text: totalIndexSize()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: watch()
+ - text: totalSize()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: getPlanCache
- type: KEYWORD
+ - text: unhideIndex()
+ type: FUNCTION
definition: ""
comment: ""
priority: 0
-- input: db.users.find().|
- want:
- - text: addOption()
+ - text: update()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: allowDiskUse()
+ - text: updateMany()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: batchSize()
+ - text: updateOne()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: close()
+ - text: updateSearchIndex()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: collation()
+ - text: validate()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: comment()
+ - text: watch()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: count()
+- input: |-
+ db.users.find().limit(20)
+ db.|
+ want:
+ - text: adminCommand()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: explain()
+ - text: aggregate()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: forEach()
+ - text: auth()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hasNext()
+ - text: changeUserPassword()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hint()
+ - text: cloneDatabase()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isClosed()
+ - text: commandHelp()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isExhausted()
+ - text: copyDatabase()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: itcount()
+ - text: createCollection()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: limit()
+ - text: createRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: map()
+ - text: createUser()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: max()
+ - text: createView()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: maxAwaitTimeMS()
+ - text: currentOp()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: maxTimeMS()
+ - text: dropAllRoles()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: min()
+ - text: dropAllUsers()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: next()
+ - text: dropDatabase()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: noCursorTimeout()
+ - text: dropRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: objsLeftInBatch()
+ - text: dropUser()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: pretty()
+ - text: fsyncLock()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: project()
+ - text: fsyncUnlock()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: projection()
+ - text: getCollectionInfos()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: readConcern()
+ - text: getCollectionNames()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: readPref()
+ - text: getLogComponents()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: returnKey()
+ - text: getMongo()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: showRecordId()
+ - text: getName()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: size()
+ - text: getProfilingLevel()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: skip()
+ - text: getProfilingStatus()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: sort()
+ - text: getReplicationInfo()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: tailable()
+ - text: getRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: toArray()
+ - text: getRoles()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: tryNext()
+ - text: getSiblingDB()
type: FUNCTION
definition: ""
comment: ""
priority: 0
-- input: db.users.find().sort().|
- want:
- - text: addOption()
+ - text: getUser()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: allowDiskUse()
+ - text: getUsers()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: batchSize()
+ - text: grantPrivilegesToRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: close()
+ - text: grantRolesToRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: collation()
+ - text: grantRolesToUser()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: comment()
+ - text: hello()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: count()
+ - text: hostInfo()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: explain()
+ - text: isMaster()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: forEach()
+ - text: killOp()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hasNext()
+ - text: listCommands()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: hint()
+ - text: logout()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isClosed()
+ - text: printCollectionStats()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: isExhausted()
+ - text: printReplicationInfo()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: itcount()
+ - text: printSecondaryReplicationInfo()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: limit()
+ - text: printShardingStatus()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: map()
+ - text: printSlaveReplicationInfo()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: max()
+ - text: revokePrivilegesFromRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: maxAwaitTimeMS()
+ - text: revokeRolesFromRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: maxTimeMS()
+ - text: revokeRolesFromUser()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: min()
+ - text: rotateCertificates()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: next()
+ - text: runCommand()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: noCursorTimeout()
+ - text: serverBuildInfo()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: objsLeftInBatch()
+ - text: serverStatus()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: pretty()
+ - text: setLogLevel()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: project()
+ - text: setProfilingLevel()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: projection()
+ - text: setSecondaryOk()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: readConcern()
+ - text: setWriteConcern()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: readPref()
+ - text: shutdownServer()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: returnKey()
+ - text: stats()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: showRecordId()
+ - text: updateRole()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: size()
+ - text: updateUser()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: skip()
+ - text: version()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: sort()
+ - text: watch()
type: FUNCTION
definition: ""
comment: ""
priority: 0
- - text: tailable()
- type: FUNCTION
+ - text: '["my-collection"]'
+ type: TABLE
definition: ""
comment: ""
priority: 0
- - text: toArray()
- type: FUNCTION
+ - text: orders
+ type: TABLE
definition: ""
comment: ""
priority: 0
- - text: tryNext()
- type: FUNCTION
+ - text: users
+ type: TABLE
definition: ""
comment: ""
priority: 0
-- input: db["users"].find().|
+- input: |-
+ db.users.find().limit(20)
+ db.users.find().|
want:
- text: addOption()
type: FUNCTION
diff --git a/go.mod b/go.mod
index 788aefddd2..ac4d697d60 100644
--- a/go.mod
+++ b/go.mod
@@ -32,7 +32,7 @@ require (
github.com/beltran/gohive/v2 v2.0.0
github.com/blang/semver/v4 v4.0.0
github.com/bmatcuk/doublestar/v4 v4.9.2
- github.com/bytebase/gomongo v0.0.0-20260127074220-ca70aee87419
+ github.com/bytebase/gomongo v0.0.0-20260130091827-042518342705
github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0
github.com/caarlos0/env/v11 v11.3.1
github.com/cenkalti/backoff/v5 v5.0.3
@@ -91,7 +91,7 @@ require (
github.com/xuri/excelize/v2 v2.10.0
github.com/yterajima/go-sitemap v0.4.0
github.com/zeebo/xxh3 v1.0.2
- go.mongodb.org/mongo-driver/v2 v2.4.2
+ go.mongodb.org/mongo-driver/v2 v2.5.0
go.uber.org/multierr v1.11.0
golang.org/x/crypto v0.47.0
golang.org/x/oauth2 v0.34.0
@@ -300,7 +300,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.41.6
github.com/aws/smithy-go v1.24.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
- github.com/bytebase/parser v0.0.0-20260127085040-91a7b9de8cfb
+ github.com/bytebase/parser v0.0.0-20260130090605-effef73942d9
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f // indirect
github.com/cockroachdb/cockroach-go/v2 v2.4.3
diff --git a/go.sum b/go.sum
index ee340443bd..fe98a266c7 100644
--- a/go.sum
+++ b/go.sum
@@ -857,12 +857,12 @@ github.com/bytebase/gh-ost2 v1.1.7-0.20251002210738-35e5dddaad7c h1:scJ4ycKuUAaA
github.com/bytebase/gh-ost2 v1.1.7-0.20251002210738-35e5dddaad7c/go.mod h1:X0CGYwIZUnjfrv02/nBlftxqSBMm4mYJzFwiyn2D4d8=
github.com/bytebase/go-mssqldb v0.0.0-20240801091126-3ff3ca07d898 h1:0ggqA9XL4yvtePPvRDRYMed3jtdNk4s0o8AMW8uJPSA=
github.com/bytebase/go-mssqldb v0.0.0-20240801091126-3ff3ca07d898/go.mod h1:2KhUz4GSLcdJGXSJMXAf2BjmakcgoOkNyPpHdGAxRpY=
-github.com/bytebase/gomongo v0.0.0-20260127074220-ca70aee87419 h1:1c35jlaOeYDpok/IUHKsYnd3UVXN8BMXJO0jAy9VvF0=
-github.com/bytebase/gomongo v0.0.0-20260127074220-ca70aee87419/go.mod h1:tmnMdRvFw6R4jYLWnPCtGMsCh2McnCXBLW4ZonyShsE=
+github.com/bytebase/gomongo v0.0.0-20260130091827-042518342705 h1:rGhKFO4BLZVJl98QXPf/wkkBAqbVOkq+SktXh459wB4=
+github.com/bytebase/gomongo v0.0.0-20260130091827-042518342705/go.mod h1:4dDI0RO2BK9/BD4VE+YqvlCj/qoVMquZ99QZdRlT8Wg=
github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0 h1:bJ8NSf2K+pccl5m/wuu97fiYjDwpJH6IzURAq/3XA2U=
github.com/bytebase/lsp-protocol v0.0.0-20250324071136-1586d0c10ff0/go.mod h1:BEWMfiZtqshdmulKJcIsWb45MUaEvDO4CROcgi8dfFg=
-github.com/bytebase/parser v0.0.0-20260127085040-91a7b9de8cfb h1:yDOH0CdAjvpm0/rRi0wvf8Em37Uehz44peqEvIvCMfU=
-github.com/bytebase/parser v0.0.0-20260127085040-91a7b9de8cfb/go.mod h1:jeak/EfutSOAuWKvrFIT2IZunhWprM7oTFBRgZ9RCxo=
+github.com/bytebase/parser v0.0.0-20260130090605-effef73942d9 h1:q5MnVPWlV/p3MPe60SysVoUaEnyeS6+OOOk0F3DLLK8=
+github.com/bytebase/parser v0.0.0-20260130090605-effef73942d9/go.mod h1:jeak/EfutSOAuWKvrFIT2IZunhWprM7oTFBRgZ9RCxo=
github.com/bytebase/pgx/v5 v5.0.0-20250212161523-96ff8aed8767 h1:YuR5G3LcxpO5ScSTA+Kdirxg9RW4TRc/v1t7N2Hfmbw=
github.com/bytebase/pgx/v5 v5.0.0-20250212161523-96ff8aed8767/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
github.com/bytebase/pkcs8 v0.0.0-20240612095628-fcd0a7484c94 h1:6PNsuNmSqCuR8Z616uQLzDIvujWCFsKzeVc3ECmVubk=
@@ -1860,8 +1860,8 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.15/go.mod h1:mXDI4NAOwEiszrHCb0aqfAYNCrZP4e9h
go.etcd.io/etcd/client/v3 v3.5.15 h1:23M0eY4Fd/inNv1ZfU3AxrbbOdW79r9V9Rl62Nm6ip4=
go.etcd.io/etcd/client/v3 v3.5.15/go.mod h1:CLSJxrYjvLtHsrPKsy7LmZEE+DK2ktfd2bN4RhBMwlU=
go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
-go.mongodb.org/mongo-driver/v2 v2.4.2 h1:HrJ+Auygxceby9MLp3YITobef5a8Bv4HcPFIkml1U7U=
-go.mongodb.org/mongo-driver/v2 v2.4.2/go.mod h1:jHeEDJHJq7tm6ZF45Issun9dbogjfnPySb1vXA7EeAI=
+go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
+go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=