masumsoft / express-cassandra

Cassandra ORM/ODM/OGM for NodeJS with support for Apache Cassandra, ScyllaDB, Datastax Enterprise, Elassandra & JanusGraph.
http://express-cassandra.readthedocs.io
GNU Lesser General Public License v3.0
228 stars 67 forks source link

Small fix to support for Azure Cosmos DB #227

Closed mike-treadway closed 3 years ago

mike-treadway commented 3 years ago

Hi, I'm trying to use Cosmos DB as my backend and it's failing to initialize the models because for whatever reason Cosmos DB doesn't support ALLOW FILTERING on the system tables. The following query is failing:

https://github.com/masumsoft/express-cassandra/blob/master/src/builders/table.js#L355

I commented out the part of the query that uses base_table_name and checked the resulting rows against it in code (instead of relying on Cassandra) and it seems to have gotten past it.

I can certainly create a PR for this change but I'm not sure if that's how you'd like to handle this (or even if you want to handle it at all). I love Express Cassandra and would really like to use it on this project so would like to see if there's anything we can do.

Options:

  1. Remove the base_table_name from the WHERE clause and check for the base_table_name when checking the view_name field. This is easy, but I can see the argument that the query is getting an unnecessary set of rows for each table. My argument would be that there would have to be a very large number of views before this makes any performance difference.
  2. Retrieve and cache the rows per keyspace, in order to limit the unnecessary rows being retrieved for each model. This technically performs better but I don't think there's enough value to warrant this level of work.

Thoughts?

mike-treadway commented 3 years ago

@masumsoft Thank you!

masumsoft commented 3 years ago

@mike-treadway Thanks for the detailed report. Option 1 is implemented and published with v2.6.0.