1.2.4 • Published 1 year ago

@bluelibs/security-mongo-bundle v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago