Download Latest Version app.27041b87bbb500531583.css.gz (92.6 kB)
Email in envelope

Get an email when there's a new version of adminos

Name Modified Size InfoDownloads / Week
Parent folder
types 2023-08-29
index.d.ts 2023-08-29 73 Bytes
index.js 2023-08-29 208 Bytes
index.js.map 2023-08-29 158 Bytes
mongo.d.ts 2023-08-29 2.3 kB
mongo.js 2023-08-29 26.8 kB
mongo.js.map 2023-08-29 11.7 kB
Totals: 7 Items   41.2 kB 0

@accounts/mongo

MongoDB adaptor for accounts

npm MIT License

Note

This package is under active development.

Install

yarn add @accounts/mongo

Usage

import { AccountsServer } from '@accounts/server';
import { Mongo } from '@accounts/mongo';

// If you are using mongoose
mongoose.connect(process.env.MONGO_URL);
const db = mongoose.connection;

// If you are using mongodb 2.x
const db = await mongodb.MongoClient.connect(process.env.MONGO_URL);

// If you are using mongodb 3.x
const client = await mongodb.MongoClient.connect(process.env.MONGO_URL);
const db = client.db('my-db-name');

const accountsMongo = new Mongo(db, options);
const accountsServer = new AccountsServer({ db: accountsMongo });

The users will be saved under the users collection.

Options

Property Type Default Description
collectionName String users The users collection name.
sessionCollectionName String sessions The sessions collection name.
timestamps Object { createdAt: 'createdAt', updatedAt: 'updatedAt' } The timestamps for the users and sessions collection.
convertUserIdToMongoObjectId Boolean true Should the user collection use _id as string or ObjectId.
convertSessionIdToMongoObjectId Boolean true Should the session collection use _id as string or ObjectId.
caseSensitiveUserName Boolean true Perform case intensitive query for user name.
idProvider Function Function that generate the id for new objects.
dateProvider (date?: Date) => any (date?: Date) => (date ? date.getTime() : Date.now()) Function that generate the date for the timestamps.
Source: README.md, updated 2023-08-29