Skip to content

thothom/core

Repository files navigation

ThothOM is an Object Mapper, an ORM + ODM, based on TypeORM syntax and ESLint plugable approach. Our intention here is standardize the connection and implementation of 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 Community Docs

Why use ThothOM?

  • 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 OM can work with all the databases, be they NoSQL or SQL, as long as it has a plugin for it.
  • No globals! All that this package uses is encapsuled inside it's classes, so there is no need to worry about some config defined in a global scope compromising your code, but if you want, you can use setGlobalConnection() to allow globals.
  • Free and direct support. If you have any question, you can join our discord community, and we and the members of Techmmunity will help you!
  • Focused on microservices and serverless! We focus in keep it usable for serverless and microservices projects.

Install and Config

With Yarn:

yarn add @thothom/core reflect-metadata

With NPM:

npm i @thothom/core reflect-metadata

Configure tsconfig.json:

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

Plugins List

All the ThothOM Plugins have the thothom tag, so you can easily found all the plugins at this link.

Plugins List

Usage

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

import { Column, Entity, PrimaryGeneratedColumn } from "@thothom/core";
// All plugins export a Connection class and a Repository type
import { Connection, Repository } from "example-thoth-plugin";

@Entity()
class FooEntity {
	@PrimaryColumn()
	public id: string;

	@Column()
	public foo: string;
}

type FooRepository = Repository<FooEntity>;

const bootstrap = async () => {
	const connection = new Connection({
		// Connection config here
		entities: [FooEntity],
	});

	await connection.load();
	await connection.connect();

	const fooRepository: FooRepository =
		connection.getRepository<FooEntity>(FooEntity);

	await fooRepository.save({
		bar: "foo",
	});

	await connection.close();
};

bootstrap();

Documentation

How to contribute?

All the details about contributing are in our website.

See here our to-dos.

Special Thanks

Contributors

This project exists thanks to all the people who contribute:

COMING SOON

Cool Kids

  • A very special thanks to the creators of TypeORM, without their code, this package would never exists.