lib/baza/driver/pg/table.rb in baza-0.0.31 vs lib/baza/driver/pg/table.rb in baza-0.0.32
- old
+ new
@@ -180,9 +180,16 @@
raise Baza::Errors::TableNotFound unless data
@data = data
self
end
+ def rows_count
+ @db.databases.with_database(database_name) do
+ sql = "SELECT COUNT(*) AS count FROM #{@db.sep_table}#{@db.escape_table(name)}#{@db.sep_table}"
+ return @db.query(sql).fetch.fetch(:count).to_i
+ end
+ end
+
def optimize
@db.query("VACUUM #{@db.sep_table}#{@db.escape_table(name)}#{@db.sep_table}")
self
end