-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(website): improve database documentation (#980)
- Loading branch information
Showing
15 changed files
with
199 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,23 @@ | ||
# @accounts/mongo | ||
|
||
_MongoDB adaptor for accounts_ | ||
[![npm](https://img.shields.io/npm/v/@accounts/mongo)](https://www.npmjs.com/package/@accounts/mongo) | ||
[![npm downloads](https://img.shields.io/npm/dm/@accounts/mongo)](https://www.npmjs.com/package/@accounts/mongo) | ||
[![codecov](https://img.shields.io/codecov/c/github/accounts-js/accounts)](https://codecov.io/gh/accounts-js/accounts) | ||
[![License](https://img.shields.io/github/license/accounts-js/accounts)](https://github.com/accounts-js/accounts/blob/master/LICENSE) | ||
|
||
[![npm](https://img.shields.io/npm/v/@accounts/mongo.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/mongo) | ||
![MIT License](https://img.shields.io/badge/license-MIT-blue.svg) | ||
A accounts-js database adapter for [MongoDB](https://www.mongodb.com/) | ||
|
||
## Note | ||
## Documentation | ||
|
||
This package is under active development. | ||
- [Website documentation](https://www.accountsjs.com/docs/databases/mongo) | ||
- [API documentation](https://www.accountsjs.com/docs/api/database-mongo/globals) | ||
|
||
## Install | ||
## Installation | ||
|
||
``` | ||
yarn add @accounts/mongo | ||
``` | ||
|
||
## Usage | ||
## Contributing | ||
|
||
In order to use the mongo adaptor in your project, you will need to pass a valid mongo connection to `@accounts/mongo`: | ||
|
||
```javascript | ||
import { MongoClient } from 'mongodb'; | ||
import { AccountsServer } from '@accounts/server'; | ||
import { Mongo } from '@accounts/mongo'; | ||
|
||
// If you are using mongodb 3.x | ||
const client = await mongodb.MongoClient.connect(process.env.MONGO_URL); | ||
const db = client.db('my-db-name'); | ||
|
||
// If you are using mongodb 2.x | ||
const db = await mongodb.MongoClient.connect(process.env.MONGO_URL); | ||
|
||
const accountsMongo = new Mongo(db, options); | ||
const accountsServer = new AccountsServer({ db: accountsMongo }); | ||
|
||
// Will create the necessary mongo indexes | ||
await accountsMongo.setupIndexes(); | ||
``` | ||
|
||
## Usage with mongoose | ||
|
||
If you are using mongoose in your application, you can reuse the mongoose connection like this: | ||
|
||
```javascript | ||
import mongoose from 'mongoose'; | ||
import { AccountsServer } from '@accounts/server'; | ||
import { Mongo } from '@accounts/mongo'; | ||
|
||
mongoose.connect(process.env.MONGO_URL); | ||
const db = mongoose.connection; | ||
|
||
const accountsMongo = new Mongo(db, options); | ||
const accountsServer = new AccountsServer({ db: accountsMongo }); | ||
|
||
// Will create the necessary mongo indexes | ||
await accountsMongo.setupIndexes(); | ||
``` | ||
|
||
The users will be saved under the `users` collection. | ||
|
||
## Setup mongodb indexes | ||
|
||
It's really important that your production database have the necessary mongodb indexes in order to perform fast queries. | ||
|
||
To do so, when your server is booting, run the following command: | ||
|
||
```javascript | ||
await accountsMongo.setupIndexes(); | ||
``` | ||
Any contribution is very welcome, read our [contributing guide](https://github.com/accounts-js/accounts/blob/master/CONTRIBUTING.md) to see how to locally setup the repository and see our development process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,25 @@ | ||
# @accounts/redis | ||
|
||
_Redis adaptor for accounts_ | ||
[![npm](https://img.shields.io/npm/v/@accounts/redis)](https://www.npmjs.com/package/@accounts/redis) | ||
[![npm downloads](https://img.shields.io/npm/dm/@accounts/redis)](https://www.npmjs.com/package/@accounts/redis) | ||
[![codecov](https://img.shields.io/codecov/c/github/accounts-js/accounts)](https://codecov.io/gh/accounts-js/accounts) | ||
[![License](https://img.shields.io/github/license/accounts-js/accounts)](https://github.com/accounts-js/accounts/blob/master/LICENSE) | ||
|
||
[![npm](https://img.shields.io/npm/v/@accounts/redis.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/redis) | ||
![MIT License](https://img.shields.io/badge/license-MIT-blue.svg) | ||
A database adapter for [Redis](https://redis.io/) | ||
|
||
## Install | ||
> For now `@accounts/redis` only provide a session storage, you will need to use another connector for the user storage. | ||
``` | ||
yarn add @accounts/redis | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
import IORedis from 'ioredis'; | ||
## Documentation | ||
|
||
import { AccountsServer } from '@accounts/server'; | ||
import { DatabaseManager } from '@accounts/database-manager'; | ||
import { RedisSessions } from '@accounts/redis'; | ||
- [Website documentation](https://www.accountsjs.com/docs/databases/redis) | ||
- [API documentation](https://www.accountsjs.com/docs/api/database-redis/globals) | ||
|
||
const ioRedis = new IORedis(); | ||
## Installation | ||
|
||
const sessionDb = new RedisSessions(ioRedis, { | ||
...options, | ||
}); | ||
``` | ||
yarn add @accounts/redis | ||
``` | ||
|
||
const accountsDb = new DatabaseManager({ | ||
sessionStorage: sessionDb, | ||
}); | ||
## Contributing | ||
|
||
const accountsServer = new AccountsServer({ db: accountsDb }); | ||
``` | ||
Any contribution is very welcome, read our [contributing guide](https://github.com/accounts-js/accounts/blob/master/CONTRIBUTING. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,23 @@ | ||
# @accounts/typeorm | ||
|
||
_TypeORM adaptor for accounts_ | ||
[![npm](https://img.shields.io/npm/v/@accounts/typeorm)](https://www.npmjs.com/package/@accounts/typeorm) | ||
[![npm downloads](https://img.shields.io/npm/dm/@accounts/typeorm)](https://www.npmjs.com/package/@accounts/typeorm) | ||
[![codecov](https://img.shields.io/codecov/c/github/accounts-js/accounts)](https://codecov.io/gh/accounts-js/accounts) | ||
[![License](https://img.shields.io/github/license/accounts-js/accounts)](https://github.com/accounts-js/accounts/blob/master/LICENSE) | ||
|
||
[![npm](https://img.shields.io/npm/v/@accounts/typeorm.svg?maxAge=2592000)](https://www.npmjs.com/package/@accounts/typeorm) | ||
![MIT License](https://img.shields.io/badge/license-MIT-blue.svg) | ||
A database adapter for [PostgreSQL](https://www.postgresql.org/) using [TypeORM](https://typeorm.io/) | ||
|
||
## Note | ||
## Documentation | ||
|
||
This package is under active development. | ||
- [Website documentation](https://www.accountsjs.com/docs/databases/typeorm) | ||
- [API documentation](https://www.accountsjs.com/docs/api/database-typeorm/globals) | ||
|
||
## Install | ||
## Installation | ||
|
||
``` | ||
yarn add @accounts/typeorm | ||
``` | ||
|
||
## Usage | ||
## Contributing | ||
|
||
```javascript | ||
import { createConnection } from 'typeorm'; | ||
import { AccountsServer } from '@accounts/server'; | ||
import { AccountsTypeorm, entities } from '@accounts/typeorm'; | ||
|
||
createConnection({ | ||
type: 'postgres', | ||
url: 'postgres://user@localhost:5432/dbname', | ||
entities, | ||
}).then(() => { | ||
const accountsTypeorm = new Typeorm(); | ||
const accountsServer = new AccountsServer({ db: accountsTypeorm }); | ||
}); | ||
``` | ||
|
||
## Options | ||
|
||
```ts | ||
type Options = { | ||
cache?: undefined | number; // Cache results from database (in ms) | ||
connection?: Connection; // Pass a connection instance | ||
connectionName?: string; // Use a connection name (if other than "default") | ||
userEntity?: typeof User; // Overwrite entities with your own | ||
userServiceEntity?: typeof UserService; | ||
userEmailEntity?: typeof UserEmail; | ||
userSessionEntity?: typeof UserSession; | ||
}; | ||
``` | ||
|
||
### Extending entities | ||
|
||
If you want to add fields, etc. to the User entity you can, by extending the base entities. | ||
|
||
```tsx | ||
import { User as AccountsUser } from '@accounts/typeorm'; | ||
|
||
@Entity() | ||
export class User extends AccountsUser { | ||
// Add fields | ||
@Column() | ||
custom_field: string; | ||
|
||
// Overwrite fields | ||
@Colum('text') | ||
profile: string; | ||
} | ||
``` | ||
Any contribution is very welcome, read our [contributing guide](https://github.com/accounts-js/accounts/blob/master/CONTRIBUTING.md) to see how to locally setup the repository and see our development process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @accounts/oauth-instagram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @accounts/oauth-twitter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @accounts/oauth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# @accounts/two-factor | ||
|
||
[![npm](https://img.shields.io/npm/v/@accounts/two-factor.svg)](https://www.npmjs.com/package/@accounts/two-factor) | ||
![MIT License](https://img.shields.io/badge/license-MIT-blue.svg) |
Oops, something went wrong.