how can I change databases/files-binary path?

89 views Asked by At

I want to create an asar file (I want to install my total.js web app in client pc, so I want to package with electron like an asar file) I need to redirect every directories have dynamic files like databases\files-binary.

So, how can I do that? I have some parameter in config file?

1

There are 1 answers

1
Molda On BEST ANSWER

You can't change default path where the files are saved.

You can:

  • use var nosql = DB.load('/path/to/database/file.nosql'); see docs https://docs.totaljs.com/latest/en.html#api~Database
  • overwrite Framework.prototype.nosql to allow you to use different path that you define in config

    //config
    //db-directory  :/some/path/to/db-directory
    
    var Path = require('path');
    framework.nosql = function(name) {
        var self = this;
        var db = self.databases[name];
        if (db)
            return db;
        db = framework_nosql.load(name, Path.join(CONFIG('db-directory'), name));
        self.databases[name] = db;
        return db;
    };
    

Change the above code to fit your needs.

Now you can use nosql just like you would normaly do:

NOSQL('files').binnary.insert(...)  
// or in beta version 2.4.0 use 
NOBIN('files').insert(...)