@bluelibs/security-mongo-bundle
v1.2.6
Published
Persistance layer using MongoDB for BlueLibs Security
Downloads
263
Readme
In this bundle we're overriding the persistence layers from SecurityBundle to make them work with MongoBundle.
Installation
npm i -S @bluelibs/security-bundle @bluelibs/security-mongo-bundle
import { SecurityBundle } from "@bluelibs/security-bundle";
import { SecurityMongoBundle } from "@bluelibs/security-mongo-bundle";
kernel.addBundle(
new SecurityBundle({
// options
}),
// Order doesn't really matter.
new SecurityMongoBundle()
);
Overriding
You have the option to make changes to your collections, for example if you user is linked to other collections or you simply want a different collectioName:
import {
UsersCollection,
PermissionsCollection,
} from "@bluelibs/security-mongo-bundle";
import { IUser } from "@bluelibs/security-bundle";
// We make the type behave with all of our needs
interface IAppUser extends IUser {
profileId: ObjectID;
}
class AppUsersCollection extends UsersCollection<IAppUser> {
static collectionName = "User"; // override it, by default it's "users"
static links = {
profile: {
collection: () => ProfilesCollection,
field: "profileId",
},
};
static indexes = [
{
key: {
profileId: 1,
},
},
];
}
new SecurityMongoBundle({
usersCollection: AppUsersCollection,
});
Support
This package is part of BlueLibs family. If you enjoy this work please show your support by starring the main package. If not, let us know what can we do to deserve it, our feedback form is here