Example #1
0
 private void EnsureTableExists(string tableName, Connection c, RethinkDb.Driver.Ast.Db db)
 {
     List<string> tables = db.TableList().Run<List<string>>(c);
     if (!tables.Contains(tableName))
     {
         logger.LogInformation("Documents table does not exist. Creating...");
         db.TableCreate(tableName).Run(c);
         logger.LogInformation("Table created");
     }
 }
Example #2
0
        public RethinkDbStore(IConfiguration config, ILogger log)
        {
            this.logger = log;
            
            string rethinkHost = config["RethinkDb:Host"];
            string dbName = config["RethinkDb:DatabaseName"];
            string tableName = config["RethinkDb:TableName"];

            ip = GetIp(rethinkHost);
            logger.LogInformation($"Initializing RethinkDb on host '{rethinkHost}' with ip {ip}");
            
            var conn = NewConnection();
            
            RethinkDb.Driver.Ast.Db db = EnsureDatabaseExists(dbName, conn);
            EnsureTableExists(tableName, conn, db);

            documentTable = db.Table(tableName);

            EnsureIndexesExist(conn);

            SubscribeToChanges(conn, config, logger);
        }