@techmmunity/compass

Compass - The ORM For All Databases

Usage no npm install needed!

<script type="module">
  import techmmunityCompass from 'https://cdn.skypack.dev/@techmmunity/compass';
</script>

README

Techmmunity - Compass

ALERT: THIS IS UNDER DEVELOPMENT AND TESTING. WE DO NOT RECOMMEND USE THIS IN PRODUCTION YET!!!

Compass is an ORM based on TypeORM syntax and ESLint plugable approach. Our intention here is standardize the database connection and implementation for every database with the best performance possible, and for this, we use an plugable approach, so more people can contribute and create their on integration. This package alone can't do anything besides typing, the plugins do all the "dirt work".

Currently it only works with TypeScript (and transpiled JavaScript), and we plan to keep this way.

Discord Badge

Why use Techmmunity Compass?

  • Easy to use and standardize. Regardless of the database, the implementation will be the same in all cases (except the most complex ones).
  • The plugable approach. With the community support, this ORM can work with all the databases, be they NoSQL or SQL, as long as it has a plugin for it.

Install and Config

With Yarn:

yarn add @techmmunity/compass

yarn add -D @types/node

With NPM:

npm i @techmmunity/compass --save

npm i @types/node --save-dev

Configure tsconfig.json:

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true
    }
}

Available Plugins

DynamoDB

Usage

Compass only supports the Data Mapper pattern, so we can avoid mutability and bad code practices.

import {
    Column,
    Entity,
    PrimaryGeneratedColumn,
    Repository,
} from "@techmmunity/compass";
// All the plugins follow this naming pattern
import { ExampleConnection } from "example-compass-plugin";

const Connection = new ExampleConnection({
    // Connection config here
});

@Entity()
class FooEntity {
    @PrimaryGeneratedColumn()
    id: string;

    @Column()
    bar: string;
}

type FooRepository = Repository<FooEntity>;

const FooRepository = Connection.getRepository(FooEntity);

FooRepository.save({
    bar: "foo",
}).then(...);

ALERT: If you use an naming pattern kebab or snake to your entities, columns, etc names, you must specify it on the connection config (at connectionOptions.namingPattern.[entity, column, etc].code), or it will be converted to camel by default.

Documentation

This is an documentation for the final user, if you want to know how to make a plugin or how to contribute to this project, give a look at this doc.

Connection

Each plugin has his own connection options, but we recommend to follow at least this base:

tableNamingPattern

The naming pattern for the tables. Accept the values: snake_case, PascalCase, CamelCase, kebab-case, UPPER_CASE and a custom function that receives a string and must return also a string.

columnNamingPattern

The naming pattern for the tables. Accept the values: snake_case, PascalCase, CamelCase, kebab-case, UPPER_CASE and a custom function that receives a string and must return also a string.

maxQueryExecutionTime

The maximum time to execute a "query", like a "timeout". Accepts a number.

Decorators

TODO

Repository

TODO

How to contribute?

All the details about contributing to the project are described here.

See here our to-dos.

Special Thanks

Contributors

This project exists thanks to all the people who contribute:

"Cool Kids" people who helped with the initial idea

  • Diozin, who suggested the name "Compass"
  • Zaetic, who make our logo