sails.js - I want to add DB connection dynamically after sails lift

前端 未结 3 1962
庸人自扰
庸人自扰 2020-12-06 07:36

During sails lift I don\'t yet have all the connection information for my DB.

Is there a way to either have config values dependent on promises or dynamically creat

3条回答
  •  孤城傲影
    2020-12-06 08:22

    Yes; two things in sails.js allow you to do this. One currently exists, and one is upcoming.

    1. https://github.com/sgress454/sails-hook-autoreload. This module watches for config file changes on disk and will re-load your ORM models when a file changes.

    2. I am working on this exact feature right now, and my plan is to publish my work at the end of next week. I agree that it will be very useful.

    The API will allow you to define new Models and Connections in the database on the fly. sails.js lifecycle callbacks handle updating the ORM and adapters and so forth. It is event-based and will allow you to manually fire events to update the ORM/Connections, like so:

    • sails.emit('hook:dynamic-orm:reload')

    Is this what you need?

提交回复
热议问题