How to use the ormnomnom.setConnection function in ormnomnom

To help you get started, we’ve selected a few ormnomnom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github entropic-dev / entropic / services / storage / middleware / postgres.js View on Github external
return function postgres(next) {
    const pool = new Pool(
      ...(url
        ? [
            {
              connectionString: url
            }
          ]
        : [])
    );
    const namespace = createNamespace('postgres');
    orm.setConnection(async () => {
      const connector = namespace.get('getConnection');
      if (typeof connector !== 'function') {
        throw new Error(
          'Accessing postgres outside the context of a request? UNACCEPTABLE'
        );
      }

      const connection = await connector();
      return {
        connection,
        release() {}
      };
    });

    return async function inner(context) {
      let client = null;

ormnomnom

a lightweight orm to silence the orm-y beast

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis