holistics / holistics/dbml

Generate DBML from JS object

Open
#514 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
3.7k
Forks
233
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Hi,
First, thank you for this project and the libraries <3

I have an object representing my db and I'm looking to generate DBML from it.
Looking at https://dbml.dbdiagram.io/js-module/#class-modelexporter I see I can generate DBML using:
```js
ModelExporter.export(database, 'postgres', false)
```
My issue is, I don't know how to generate a `database` value with `Database` type :disappointed:

In the example it's build using the parser but I don't have DBML as input.

I saw the `Database` class is exported here: [dbml-core/src/model_structure/database.js](https://github.com/holistics/dbml/blob/master/packages/dbml-core/src/model_structure/database.js), and I tried to import it using:
```js
import Database from "@dbml/core/types/model_structure/database";
```

But it gives me the error: `Cannot find module '@dbml/core/types/model_structure/database' from 'src/dbml.ts'`

And when I try:
```js
import Database from "@dbml/core/model_structure/database";
```
I got the error: `Cannot find module '@dbml/core/model_structure/database' or its corresponding type declarations.`

Do you have any idea how I can configure TypeScript to match modules and type definitions or how I can create a Database class?
I think it would be nice to export the models in `model_structure` in the `index.js`, what do you think?
Also, I don't know the difference between a Database and a NormalizedDatabase, is there any explanation somewhere?

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.