[Mastra] Bring your own collection (assessment)

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: ABX
    • None
    • None
    • None
    • None
    • None
    • None

      Through #19805, you can now point a Mastra vector index at a MongoDB collection you already have, no copying them into a separate Mastra-managed collection and no job to keep the two in sync. Your original data is read-only by default, and queries can return the full source document.

      const store = new MongoDBVector({ id: 'mongodb-vector', uri, dbName })
      
      // Put a vector index on an EXISTING 'transactions' collection (never created/dropped by the store)
      await store.createIndex({
        indexName: 'precedents',
        dimension: 1024,
        collectionName: 'transactions',
        // allowWrites: true,   // opt-in; otherwise upsert/update/delete throw (read-only by default)
      })
      await store.waitForIndexReady({ indexName: 'precedents' })
      
      // Query in 'document' mode to get the full source document back as metadata
      const hits = await store.query({
        indexName: 'precedents',
        queryVector: embedding,
        topK: 5,
        metadataMode: 'document',        // full operational doc in hits[].metadata
        filter: { lane: 'fraud' },        // in 'document' mode, matches ROOT fields (no metadata. prefix)
      })
      
      // Full-text / hybrid on a BYO collection is opt-in — provision the text index first
      await store.createSearchIndex({ indexName: 'precedents', fields: ['note'] })

       

      Task

      1. Security review of this feature
      2. Update documentation to show the differentiated value proposition of this feature vs other database backends

            Assignee:
            Casey Clements
            Reporter:
            Raschid Jimenez
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: