Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config variable dynamically thru app.set #2325

Closed
swina opened this issue Apr 30, 2021 · 2 comments · Fixed by #2367
Closed

Update config variable dynamically thru app.set #2325

swina opened this issue Apr 30, 2021 · 2 comments · Fixed by #2367

Comments

@swina
Copy link

swina commented Apr 30, 2021

Steps to reproduce

Using nedb as local data I'm trying to switch between 2 different folders using app.set ( 'nedb' , new_path ) thru a hook.


...
    //change nedb path
    context.app.set ( 'nedb' , path.resolve ( data_folder ) )
   //reconfigure services
   const services = require ( '../services' )
   context.app.configure ( services )
   //checking if current data folder is correct
   console.log ( context.app.get('nedb') )
...  

Expected behavior

Any service after the data folder update thru app.set should use the database in the updated folder

Actual behavior

After set a new path for nedb any query still refers to the nedb path variable defined in the default.json

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working): above code example is set in a hook

NodeJS version: 12.22

Operating System: Win10

Browser Version: Chrome latest

React Native Version: NA

Module Loader: NA

@daffl
Copy link
Member

daffl commented May 24, 2021

This is currently not possible. The database model is initialized on application startup. The upcoming v5 will allow passing params.adapter.Model where you can set the model you would like to use for the request.

@swina
Copy link
Author

swina commented May 25, 2021

Thank you for your answer! Waiting v5 !
Great job
Antonio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants