npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dbschema-parser

v1.2.3

Published

Parses DBSchema document into JavaScript. Exports to JSON.

Downloads

33

Readme

dbschema-parser

Parses .dbs files from the DbSchema Diagram Designer and Query Tool from Wise Coders Solutions.

Installation

npm install dbschema-parser

Usage

Initializing the Parser

var dbSchema  = require('dbschema-parser');
var parser = new dbSchema.Parser(filePath);

Rendered Objects


Parser

Single instance. Top-most object.

Properties
  • databases: array[Database] : Array of Database objects.
  • path: string : Path to supplied .dbs file.
  • xml: string : Contents of .dbs file in raw XML format.
  • object: object : Parsed .dbs file in JSON object format.
  • json: string : Parsed .dbs file in pretty-printed JSON format (non-object).

Database

Extrapolation of the DbSchema Project object. Assumes all schemas are contained within a single database.

Properties
  • parser: Parser : Reference to parent Parser object.
  • project: object : Reference to raw DbSchema object in JSON object format.
  • name: string : Name of database.
  • id: string : ID of Project, as supplied by DbSchema.
  • template: string : Template of Project, as supplied by DbSchema.
  • type: string : Database type (ie, MySql, MariaDb, MongoDb, etc.).
  • schemas: array[Schema] : Array of Schema objects contained within Database

Schema

Properties
  • database: Database: Reference to parent Database object.
  • schema: object: Reference to raw DbSchema object in JSON object format.
  • name: string: Name of schema.
  • tables: array[Table]: Array of Table objects contained within Database.
  • views: array[Table]: Array of Table objects contained within Database.

Table

Note: Due to the near-identical structure of both, the Table object is used for both tables and views.

Properties
  • schema: Schema: Reference to parent Schema object.
  • table: object: Reference to raw DbSchema object in JSON object format.
  • name: string: Name of table or view.
  • keyColumns: array[Column]: Array of Column objects within this primary key Table Index.
  • isView: boolean: Indicates whether the table is actually a view.
  • columns: array[Column]: Array of Column objects contained within the Table.
  • indices: array[TableIndex]: Array of Table Index objects contained within the Table.

Column

Properties
  • table: Table: Reference to parent Table object.
  • column: object: Reference to raw DbSchema object in JSON object format.
  • name: string: Name of column.
  • type: string: Type of column.
  • length: number: If supplied, the length of the column.
  • jt: number: (See DbSchema documentation.)
  • isPrimary: boolean: Column a member of the primary key index.
  • mandatory: boolean: Column is required or NOT NULL
  • relationships: array[Column]: (not required) Any columns referencing this column in a foreign key.
  • parent: object: (not required) The target PK column if a foreign key exists:
parent: {
    schema: {
        name: '',
        item:
    },
    table: {
        name: '',
        item:
    },
    column: {
        name: '',
        item:
    }
}

Table Index

Properties
  • table: Table: Reference to parent Table object.
  • index: object: Reference to raw DbSchema object in JSON object format.
  • name: string: Name of index (usually generated by database or DbSchema).
  • columns: array[Column]: Array of Column objects within this index.
  • type: string: Type name, as supplied by DbSchema (ie, NORMAL, PRIMARY_KEY, UNIQUE, etc.).
  • isUnique: boolean: Indicates if the column combination must be unique (also true for the primary key).
  • isPrimary: boolean: Table Index is the primary key.

Operations

Generally speaking, the Parser is meant to be used for navigating, or "walking", the DbSchema-generated hierarchy. However, for convenience, one operation is available:

print(spacing)

Prints the hierarchy in a human-readable YML-like indented structure:

Database: resources
    Schema: geography
        Table: city
            Column: id
                Relationships:
                    resources.geography.postal_code.city_id
            Column: state_id
                Primary:
                    Schema: geography
                    Table:  state
                    Column: id
            Column: name
            Index: idx_city (UNIQUE)
                Column: state_id
                    Primary:
                        Schema: geography
                        Table:  state
                        Column: id
                Column: name
            Index: idx_city_0 (NORMAL)
                Column: state_id
                    Primary:
                        Schema: geography
                        Table:  state
                        Column: id
            Index: pk_city (PRIMARY_KEY)
                Column: id
        Table: country
            Column: id
                Relationships:
                    resources.geography.postal_code.country_id
                    resources.geography.state.country_id
            Column: name
            Index: idx_country (UNIQUE)
                Column: name
            Index: pk_country (UNIQUE)
                Column: id
        Table: postal_code
            Column: id
            Column: country_id
                Primary:
                    Schema: geography
                    Table:  country
                    Column: id
            Column: state_id
                Primary:
                    Schema: geography
                    Table:  state
                    Column: id
            Column: city_id
                Primary:
                    Schema: geography
                    Table:  city
                    Column: id
            Column: value
            Index: pk_postal_code (PRIMARY_KEY)
                Column: id
            Index: idx_postal_code (UNIQUE)
                Column: country_id
                    Primary:
                        Schema: geography
                        Table:  country
                        Column: id
                Column: state_id
                    Primary:
                        Schema: geography
                        Table:  state
                        Column: id
                Column: city_id
                    Primary:
                        Schema: geography
                        Table:  city
                        Column: id
                Column: value
            Index: idx_postal_code_0 (NORMAL)
                Column: country_id
                    Primary:
                        Schema: geography
                        Table:  country
                        Column: id
            Index: idx_postal_code_1 (NORMAL)
                Column: state_id
                    Primary:
                        Schema: geography
                        Table:  state
                        Column: id
            Index: idx_postal_code_2 (NORMAL)
                Column: city_id
                    Primary:
                        Schema: geography
                        Table:  city
                        Column: id
        Table: state
            Column: id
                Relationships:
                    resources.geography.city.state_id
                    resources.geography.postal_code.state_id
            Column: country_id
                Primary:
                    Schema: geography
                    Table:  country
                    Column: id
            Column: name
            Index: idx_state (UNIQUE)
                Column: country_id
                    Primary:
                        Schema: geography
                        Table:  country
                        Column: id
                Column: name
            Index: idx_state_0 (NORMAL)
                Column: country_id
                    Primary:
                        Schema: geography
                        Table:  country
                        Column: id
            Index: pk_state_0 (PRIMARY_KEY)
                Column: id

About MEAN Factory

MEAN Factory is an initiative to help teach software development focusing on the MEAN Stack (Mongo, ExpressJS, AngularJS, NodeJS). For more information, visit our web site or email us:

http://meanfactory.com
[email protected]