1 | # Odin
|
2 |
|
3 | Odin 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.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 | - [Odin](#odin)
|
26 | - [Installation](#installation)
|
27 | - [Usage](#usage)
|
28 | - [Features](#features)
|
29 | - [TODO (RoadMap to version 1.0.0)](#todo-roadmap-to-version-100)
|
30 | - [Support](#support)
|
31 |
|
32 | ## Installation
|
33 |
|
34 | Before installing, [download and install Node.js](https://nodejs.org/en/download).
|
35 | Node.js 8 or higher is required.
|
36 |
|
37 | ```bash
|
38 | npm i -s @foxify/odin
|
39 | ```
|
40 |
|
41 | ## Usage
|
42 |
|
43 | ```javascript
|
44 | const Odin = require("@foxify/odin");
|
45 |
|
46 | const { Types } = Odin;
|
47 |
|
48 | class User extends Odin {
|
49 | }
|
50 |
|
51 | User.schema = {
|
52 | email: Types.String.email.required,
|
53 | name: {
|
54 | first: Types.String.min(3).required,
|
55 | last: Types.String.min(3),
|
56 | }
|
57 | };
|
58 | ```
|
59 |
|
60 | ## Features
|
61 |
|
62 | 1. Written in `ES6`
|
63 | 2. `TypeScript` ready
|
64 | 3. `Active Record` pattern
|
65 | 4. `Schema` validation
|
66 | 5. `GraphQL Schema` generator (based on model schema)
|
67 | 6. `JSON Schema` generator (based on model schema)
|
68 |
|
69 | ## TODO (RoadMap to version 1.0.0)
|
70 |
|
71 | - [x] `Schema` validation
|
72 | - [ ] Model
|
73 | - [ ] Hooks
|
74 | - [x] `create`
|
75 | - [ ] `update`
|
76 | - [ ] `delete`
|
77 | - [ ] `restore`
|
78 | - [ ] Relationships
|
79 | - [x] `embedMany`
|
80 | - [x] `hasMany`
|
81 | - [x] `hasOne`
|
82 | - [ ] `hasManyThrough`
|
83 | - [ ] `hasOneThrough`
|
84 | - [ ] `Polymorphic`
|
85 | - [x] `morphMany`
|
86 | - [x] `morphOne`
|
87 | - [ ] `morphTo`
|
88 | - [ ] `morphManyThrough`
|
89 | - [ ] `morphOneThrough`
|
90 | - [ ] `morphToThrough`
|
91 | - [x] CRUD operations
|
92 | - [x] Create operation
|
93 | - [x] Read operation
|
94 | - [x] Update operation
|
95 | - [x] Delete operation
|
96 | - [x] `GraphQL` support
|
97 | - [x] `JSON Schema` support
|
98 | - [ ] Migrations
|
99 | - [ ] Seeding
|
100 | - [ ] Tests
|
101 |
|
102 | ## Support
|
103 |
|
104 | If my work helps you, please consider
|
105 |
|
106 | [![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/ardalanamini)
|
107 | [![Become A Patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/ardalanamini)
|