0

OrientDB で SailsJS を使用したい (NodeJS には Oriento を使用)。データベース接続を確立および定義して、すべてのモデルで使用できるようにするのに適切な場所はどこですか?

接続の値を config/connections.js に配置し、接続自体をカスタム ミドルウェアとして /config/http.js に配置しました。それは機能しますが、それが正しいかどうかは絶対にわかりません

module.exports.http = {

  middleware: {
      custom: true
    },
   customMiddleware: function(app){

      var Oriento = require('oriento');
      var Oserver = Oriento({
        host: sails.config.connections.orientDBServer.host,
        port: sails.config.connections.orientDBServer.port,
        username: sails.config.connections.orientDBServer.username,
        password: sails.config.connections.orientDBServer.password
      });

      db = Oserver.use({
        name: sails.config.connections.orientDBServer.dbname,
        username: sails.config.connections.orientDBServer.username,
        password: sails.config.connections.orientDBServer.password
      });
   }
}
4

1 に答える 1