Is there a way to use massivejs and use dynamic variable for table name to create table and select table?

113 Views Asked by At

I have setup a postgreSQL access through a node server using express and massive, but I cannot find a way to build new tables with dynamic table names or select a table dynamically using massive. Any direction would be most appreciated!

1

There are 1 best solutions below

0
dmfay On
  1. You can create dynamic SQL through script files. Massive does exactly what you're intending internally when you create document tables.

  2. Tables (and other database objects) are properties on the db object so you can use bracket accessor syntax with a variable, viz. await db[thisOrThatTableName].find(...).