【发布时间】:2017-01-22 05:19:05
【问题描述】:
我觉得这个问题很简单,但令我惊讶的是根本没有找到任何文档或信息。我只是想获取或计算单个 couchbase 数据库的大小(以字节为单位)。
例如,我有一个数据库,用于存储经销商处汽车的所有信息。数据库中有多个文档。我想弄清楚如何计算数据库的非压缩总大小。这包括数据库中的所有内容(附件、文本、所有内容)
理想情况下,使用 Swift 3.0。但是,如果有人知道如何获取任何语言的数据库大小,我可以将语言移植到 swift。
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?
}
【问题讨论】:
-
我认为这是关于 Couchbase Mobile,因为您使用的是 Swift?
标签: swift database size couchbase