I want to compact a Realm file in my Node JS app, but there is nothing about it in the Realm JS docs.
I dug into the JS API reference, but the usage is vague (at least to me).
Here's what I've tried so far:
//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)
})
}
Does this even work? Does it just overwrite the existing realm file to be compacted?