1.0.5 • Published 4 years ago

moleculer-simple-mysql v1.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Moleculer Simple MySQL Mixin

Provide this.db object in service with async queries.

Prepare

Set env MYSQL_URL (see: example.env)

Methods

  • query
  • results
  • row
  • col
  • var
  • insert

Use

In service

const Db = require('moleculer-simple-mysql');
module.exports = {
    name: 'test',
    mixins: [Db],
    actions: {
        test: {
            rest: {method:'POST'},
            handler() {
                // Direct return promise
                return this.db.val(`SELECT NOW()`);            
            }        
        },
        test2: {
            rest: {method:'POST'},
            async handler() {
                // async/await
                const now = await this.db.val(`SELECT NOW()`); 
                return `Now: ${now}`;             
            }        
        }       
    }
};
1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago