Lowdb resetting whenever glitch autorefreshes the bot

Hi there!
i’m currently trying to save some data on my bot via the library LowDB (as suggested by glitch), but whenever the project “autorefreshes” the values go back to default, so for example, if i modified this

{
    "guilds": {
        "675021275738931221": {
            "prefix": "nm ",
            "locale": "en"
        }
    }
}

in this

{
    "guilds": {
        "675021275738931221": {
            "prefix": "nm ",
            "locale": "es"
        }
    }
}

the app will reset the “es” to “en” on restart (en is the default value assigned)


here’s the project

hope you’ll be able to help me!

Can you share the code you use to open the lowdb object?

if you’re talking about the chunk of code i use to set the value,
here it is

    message.client.db.get(`guilds.${message.guild.id}`)
      .assign({locale: args[0].toLowerCase()})
       .value();

but if you’re talking about how I actually initializate lowdb, here it is

var low = require('lowdb')
var FileSync = require('lowdb/adapters/FileSync')
var adapter = new FileSync('.data/db.json')
var db = low(adapter)

plus the now removed (without causing any trouble) default file content

db.defaults({ guilds: {} })
  .write()

Seems you’re missing to execute .write() on the assign method.

The code below should fix your issue.

message.client.db.get(`guilds.${message.guild.id}`)
  .assign({ locale: args[0].toLowerCase() })
  .write();