I feel that the question is simple yet I was surprised to not find any documentation nor information on it at all. I simply want to get or compute the size in bytes of a single couchbase database.
For example, I have a database that stores all the information of cars at a dealership. There are multiple documents within the database. I would like to figure out how to compute the non-compressed total size of the database. This include everything in the database (attachments, text, everything)
Ideally, using Swift 3.0. However, I can port over language to swift if anyone knows how to get the database size in any language.
func openDatabase() -> CBLDatabase
{
var db : CBLDatabase?
let db_name = "dealership"
let options = CBLDatabaseOptions()
options.create = true
do
{
// This will create a database if one does not exist. Otherwise, it will open it.
try db = CBLManager.sharedInstance().openDatabaseNamed(db_name, with: options)
// I would love if this was a thing! Since it is not, I would like to write a function to get the database size.
let db_size = db.getSize() // <-- This is my question. How to compute the database size.
}
catch let error as NSError
{
NSLog("Some error %@", error)
}
return db
}
/** Gets the size of the database in MB */
func getSize() -> Int
{
// What goes here?
}