https://github.com/multum/metalize
Node.js tool for easy reading database metadata
https://github.com/multum/metalize
database metadata mysql postgres postgresql structure
Last synced: 9 months ago
JSON representation
Node.js tool for easy reading database metadata
- Host: GitHub
- URL: https://github.com/multum/metalize
- Owner: multum
- License: mit
- Created: 2019-08-30T13:45:27.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2021-04-12T02:07:16.000Z (about 5 years ago)
- Last Synced: 2025-09-21T05:35:28.498Z (9 months ago)
- Topics: database, metadata, mysql, postgres, postgresql, structure
- Language: JavaScript
- Homepage: https://multum.github.io/metalize
- Size: 171 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Node.js tool for easy work with database metadata
## Features
- Fully tested
- Fully documented
- **PostgreSQL** and **MySQL** dialects
- [**Tables**](https://multum.github.io/metalize/#/metadata/table)
- Detailed [column](https://multum.github.io/metalize/#/metadata/column) metadata
- Multi-column constraints
- [Indexes](https://multum.github.io/metalize/#/metadata/index)
- [**Sequences**](https://multum.github.io/metalize/#/metadata/sequence)
## Documentation
- [Documentation](https://multum.github.io/metalize/#/)
- [Contributing](https://github.com/multum/metalize/blob/main/CONTRIBUTING.md)
## Getting Started
```bash
npm install metalize pg # postgres
npm install metalize mysql2 # mysql
```
> **Do not use quotes** in the name of the object. `Metalize` automatically adds them when needed
```javascript
const Metalize = require('metalize');
const metalize = new Metalize({
dialect: 'postgres', // one of [ 'postgres', 'mysql' ]
connectionConfig: {
host: '127.0.0.1',
port: 5432,
// other connection options for dialect
},
});
metalize
.find({
tables: ['public.users', 'public.events'],
sequences: ['public.usersSeq'], // only for 'postgres' dialect
})
.then((result) => console.log(result));
/**
Result {
'tables': Map {
'public.users' => {
columns: [ ... ],
primaryKey: { ... },
foreignKeys: [ ... ],
unique: [ ... ],
indexes: [ ... ],
checks: [ ... ]
},
'public.events' => { ... }
}
'sequences': Map {
'public.usersSeq' => {
start: '1',
min: '1',
max: '9999',
increment: '1',
cycle: true,
}
}
}
*/
```
## Using an existing connection
```javascript
const Metalize = require('metalize');
const { Client } = require('pg');
const client = new Client({
host: '127.0.0.1',
port: 5432,
database: 'postgres',
user: 'postgres',
password: 'postgres',
});
client.connect();
/**
* or using 'mysql' dialect
* @example
* const { createConnection } = require('mysql2/promise');
* const client = await createConnection(...)
*/
const metalize = new Metalize('postgres');
metalize
.find({ tables: ['public.users'] }, { client })
.then((result) => console.log(result));
/**
* A new connection will not be opened
* Instead, the connection from the 'options' will be used
*/
```
## License
**Metalize** is open source software [licensed as MIT](https://github.com/multum/metalize/blob/main/LICENSE).