pub async fn list_all(db: &PgPool) -> Result<Vec<Table>, sqlx::Error> {
        let pts = sqlx::query_as!(PrimitiveTable, "SELECT * FROM tables ORDER BY created_at")
            .fetch_all(db)
            .await?;

        let mut schema_map = HashMap::new();
        let mut schemas: Vec<Schema> = Schema::list_all(db).await?;
        for schema in schemas.drain(0..) {
            schema_map.insert(schema.id, schema);
        }

        debug!("schema_map: {:?}", schema_map);

        Ok(pts
            .into_iter()
            .map(|inner| {
                let schema = schema_map.get(&inner.schema_id).unwrap().clone();

                Table {
                    inner,
                    schema,
                    delta_table: None,
                }
            })
            .collect())
    }
/**
     * List all the tables that exist in the database
     */
List all the tables that exist in the database
List all the tables that exist in the database
pub async fn list_all(db: &PgPool) -> Result<Vec<Table>, sqlx::Error> {
        let pts = sqlx::query_as!(PrimitiveTable, "SELECT * FROM tables ORDER BY created_at")
            .fetch_all(db)
            .await?;
        let mut schema_map = HashMap::new();
        let mut schemas: Vec<Schema> = Schema::list_all(db).await?;
        for schema in schemas.drain(0..) {
            schema_map.insert(schema.id, schema);
        }
        debug!("schema_map: {:?}", schema_map);
        Ok(pts
            .into_iter()
            .map(|inner| {
                let schema = schema_map.get(&inner.schema_id).unwrap().clone();
                Table {
                    inner,
                    schema,
                    delta_table: None,
                }
            })
            .collect())
    }
pub async fn list_all ( db : & PgPool ) -> Result < Vec < Table > , sqlx :: Error > { let pts = sqlx :: query_as ! ( PrimitiveTable " " ) . fetch_all ( db ) . await ? ; let mut schema_map = HashMap :: new ( ) ; let mut schemas : Vec < Schema > = Schema :: list_all ( db ) . await ? ; for schema in schemas . drain ( 0 .. ) { schema_map . insert ( schema . id , schema ) ; } debug ! ( " " schema_map ) ; Ok ( pts . into_iter ( ) . map ( | inner | { let schema = schema_map . get ( & inner . schema_id ) . unwrap ( ) . clone ( ) ; Table { inner , schema , delta_table : None , } } ) . collect ( ) ) }
List all the tables that exist in the database
List all the tables that exist in the database
db
&PgPool
db
&PgPool