0.1.39 • Published 10 months ago

senselogic-eureka v0.1.39

Weekly downloads
-
License
LGPL-3.0-only
Repository
github
Last release
10 months 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

11 months ago

0.1.34

10 months ago

0.1.35

10 months ago

0.1.36

10 months ago

0.1.37

10 months ago

0.1.38

10 months ago

0.1.39

10 months ago

0.1.32

1 year ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.19

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.16

2 years ago

0.1.8

2 years ago

0.1.17

2 years ago

0.1.7

2 years ago

0.1.18

2 years ago

0.1.9

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago