0.1.39 • Published 2 years ago

senselogic-eureka v0.1.39

Weekly downloads
-
License
LGPL-3.0-only
Repository
github
Last release
2 years ago

npm.io

Eureka

Minimalistic ORM for MySQL and PostgreSQL databases.

Sample

import { Database } from 'senselogic-eureka';
import { Mysql2Driver } from 'senselogic-eureka-mysql2';

const database = new Database( process.env.MYSQLDATABASE ?? 'eureka_project_db' );

const propertyTable
    = database.addTable(
        'PROPERTY',
        [
            [ 'id', 'TUID', [ 'key' ] ],
            [ 'number', 'FLOAT64' ],
            [ 'city', 'STRING' ],
            [ 'country', 'STRING' ],
            [ 'title', 'STRING' ],
            [ 'description', 'STRING' ],
            [ 'price', 'FLOAT64' ],
            [ 'userId', 'TUID' ],
            [ 'updateTimestamp', 'TIMESTAMP' ]
        ]
        );

const propertyImageTable
    = database.addTable(
        'PROPERTY_IMAGE',
        [
            [ 'id', 'TUID', [ 'key' ] ],
            [ 'number', 'FLOAT64' ],
            [ 'propertyId', 'TUID' ],
            [ 'filePath', 'STRING' ],
            [ 'userId', 'TUID' ],
            [ 'updateTimestamp', 'TIMESTAMP' ]
        ]
        );

const userTable
    = database.addTable(
        'USER',
        [
            [ 'id', 'TUID', [ 'key' ] ],
            [ 'firstName', 'STRING' ],
            [ 'lastName', 'STRING' ],
            [ 'email', 'STRING' ],
            [ 'passwordHash', 'STRING' ],
            [ 'updateTimestamp', 'TIMESTAMP' ]
        ]
        );

database.setDriver( new Mysql2Driver() );

await database.createConnection(
    {
        host: process.env.MYSQLHOST ?? 'localhost',
        port: process.env.MYSQLPORT ?? 3306,
        user: process.env.MYSQLUSER ?? 'root',
        password: process.env.MYSQLPASSWORD ?? ''
    }
    );

let propertyId = '4NB6wwkg6gQpZpkN1HSf7A';
let property = await propertyTable.selectRow(
    {
        where : [ [ 'id' ], '=', propertyId ]
    }
    );

let propertyImageArray = await propertyImageTable.selectRows(
    {
        where : [ [ 'propertyId' ], '=', params.propertyId ],
        order : 'number'
    }
    );

await propertyTable.updateRow(
    {
        'id' : propertyId,
        'number' : 1
    }
    );

property.id = 'BgsTcQuBCqeEZFwYLFpTKQ';
property.number = 2;
await propertyTable.insertRow( property );

Version

0.1

Author

Eric Pelzer (ecstatic.coder@gmail.com).

License

This project is licensed under the GNU Lesser General Public License version 3.

See the LICENSE.md file for details.

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.37

2 years ago

0.1.38

2 years ago

0.1.39

2 years ago

0.1.32

2 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.27

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.19

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.8

3 years ago

0.1.17

3 years ago

0.1.7

3 years ago

0.1.18

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago