1

我想在我的 Node JS 应用程序中压缩一个 Realm 文件,但在Realm JS 文档中没有任何内容。

我深入研究了JS API 参考,但用法很模糊(至少对我而言)。

这是我到目前为止所尝试的:

//This is my own custom function
function compactRealmFile(path){
  return Realm.open({ path: path }).then(realm => {
    if(realm.compact()){
      //-- Successful compaction --
      return Promise.resolve()
    }else{
      return Promise.reject('Compaction error!')
    }
  })
  .catch(error => {
    return Promise.reject('Realm compaction error: '+error)
  })
}

这甚至行得通吗?它是否只是覆盖要压缩的现有领域文件?

4

0 回答 0