UNPKG

4.15 kBMarkdownView Raw
1# Odin <!-- omit in toc -->
2
3Odin is an implementation of [**Active Record**](https://en.wikipedia.org/wiki/Active_record_pattern) pattern in [**TypeScript**](https://typescriptlang.com).
4
5[![NPM Version](https://img.shields.io/npm/v/@foxify/odin.svg)](https://www.npmjs.com/package/@foxify/odin)
6[![Node Version](https://img.shields.io/node/v/@foxify/odin.svg)](https://nodejs.org)
7[![TypeScript Version](https://img.shields.io/npm/types/@foxify/odin.svg)](https://www.typescriptlang.org)
8[![Tested With Jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
9[![Pull Requests](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/foxifyjs/odin/pulls)
10[![License](https://img.shields.io/github/license/foxifyjs/odin.svg)](https://github.com/foxifyjs/odin/blob/master/LICENSE)
11[![Build Status](https://api.travis-ci.com/foxifyjs/odin.svg?branch=master)](https://travis-ci.com/foxifyjs/odin)
12[![Coverage Status](https://codecov.io/gh/foxifyjs/odin/branch/master/graph/badge.svg)](https://codecov.io/gh/foxifyjs/odin)
13[![Package Quality](http://npm.packagequality.com/shield/%40foxify%2Fodin.svg)](http://packagequality.com/#?package=@foxify/odin)
14[![Dependencies Status](https://david-dm.org/foxifyjs/odin.svg)](https://david-dm.org/foxifyjs/odin)
15[![NPM Total Downloads](https://img.shields.io/npm/dt/@foxify/odin.svg)](https://www.npmjs.com/package/@foxify/odin)
16[![NPM Monthly Downloads](https://img.shields.io/npm/dm/@foxify/odin.svg)](https://www.npmjs.com/package/@foxify/odin)
17[![Open Issues](https://img.shields.io/github/issues-raw/foxifyjs/odin.svg)](https://github.com/foxifyjs/odin/issues?q=is%3Aopen+is%3Aissue)
18[![Closed Issues](https://img.shields.io/github/issues-closed-raw/foxifyjs/odin.svg)](https://github.com/foxifyjs/odin/issues?q=is%3Aissue+is%3Aclosed)
19[![known vulnerabilities](https://snyk.io/test/github/foxifyjs/odin/badge.svg?targetFile=package.json)](https://snyk.io/test/github/foxifyjs/odin?targetFile=package.json)
20[![Github Stars](https://img.shields.io/github/stars/foxifyjs/odin.svg?style=social)](https://github.com/foxifyjs/odin)
21[![Github Forks](https://img.shields.io/github/forks/foxifyjs/odin.svg?style=social&label=Fork)](https://github.com/foxifyjs/odin)
22
23## Table of Content <!-- omit in toc -->
24
25- [Installation](#installation)
26- [Usage](#usage)
27- [Features](#features)
28- [TODO (RoadMap to version 1.0.0)](#todo-roadmap-to-version-100)
29- [Support](#support)
30
31## Installation
32
33Before installing, [download and install Node.js](https://nodejs.org/en/download).
34Node.js 8 or higher is required.
35
36```bash
37npm i -s @foxify/odin
38```
39
40## Usage
41
42```javascript
43const Odin = require("@foxify/odin");
44
45const { Types } = Odin;
46
47class User extends Odin {
48}
49
50User.schema = {
51 email: Types.String.email.required,
52 name: {
53 first: Types.String.min(3).required,
54 last: Types.String.min(3),
55 }
56};
57```
58
59## Features
60
611. Written in `ES6`
622. `TypeScript` ready
633. `Active Record` pattern
644. `Schema` validation
655. `GraphQL Schema` generator (based on model schema)
666. `JSON Schema` generator (based on model schema)
67
68## TODO (RoadMap to version 1.0.0)
69
70- [x] `Schema` validation
71- [ ] Model
72 - [ ] Hooks
73 - [x] `create`
74 - [ ] `update`
75 - [ ] `delete`
76 - [ ] `restore`
77 - [ ] Relationships
78 - [x] `embedMany`
79 - [x] `hasMany`
80 - [x] `hasOne`
81 - [ ] `hasManyThrough`
82 - [ ] `hasOneThrough`
83 - [ ] `Polymorphic`
84 - [x] `morphMany`
85 - [x] `morphOne`
86 - [ ] `morphTo`
87 - [ ] `morphManyThrough`
88 - [ ] `morphOneThrough`
89 - [ ] `morphToThrough`
90 - [x] CRUD operations
91 - [x] Create operation
92 - [x] Read operation
93 - [x] Update operation
94 - [x] Delete operation
95 - [x] `GraphQL` support
96 - [x] `JSON Schema` support
97- [ ] Migrations
98- [ ] Seeding
99- [ ] Tests
100
101## Support
102
103If my work helps you, please consider
104
105[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/ardalanamini)
106[![Become A Patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/ardalanamini)