Search code examples
mongodbdeepstream.io

Deepstream query with MongoDB


I have been looking around in the internet on how to query MongoDB using Deepstream. I followed their documentation but it is not working, here is my sample code:

const testQuery = JSON.stringify({
  table: 'test',
  query: [
    [ 'name', 'eq', 'test2' ]
  ]
})
const results = client.record.getList('search?' + testQuery);
results.whenReady((res)=>{
  console.log(results);
})

Is there something missing? I am not using RethinkDB, I am connected directly to my mongonDb. Thanks in advance.


Solution

  • The MongoDB connector is not set up to do queries of any sort. The Deepstream storage connectors are primarily purposed to convert Deepstream objects into a format that the database can store and persist until the data needs to be retrieved when it's not available in the cache.

    https://deepstream.io/tutorials/integrations/db-mongodb/

    They can be written to do more, but generally in order to achieve that you'd have to start specifying a more rigid schema in your database because the Deepstream connector API is pretty limited and only exposes GET, SET, and DELETE operations to the connectors.

    It sounds like ElasticSearch is more what you're looking for

    https://deepstream.io/tutorials/integrations/db-elasticsearch/