From 743288135c67750e1d0966c1fece1c8b62f4f01b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E6=9D=89?= Date: Tue, 15 Sep 2020 23:08:31 +0800 Subject: [PATCH] chore: bump to 2.2.2 (#22) --- API.md | 84 ++++++++++++++++------------------------------------ package.json | 2 +- 2 files changed, 26 insertions(+), 60 deletions(-) diff --git a/API.md b/API.md index 1106901..17990d0 100644 --- a/API.md +++ b/API.md @@ -37,9 +37,7 @@ Implements a policy adapter for casbin with MongoDB support. ### new MongooseAdapter(uri, [options]) -Creates a new instance of mongoose adapter for casbin. -It does not wait for successfull connection to MongoDB. -So, if you want to have a possibility to wait until connection successful, use newAdapter instead. +Creates a new instance of mongoose adapter for casbin. It does not wait for successfull connection to MongoDB. So, if you want to have a possibility to wait until connection successful, use newAdapter instead. | Param | Type | Default | Description | @@ -49,8 +47,7 @@ So, if you want to have a possibility to wait until connection successful, use n **Example** ```js -const adapter = new MongooseAdapter('MONGO_URI'); -const adapter = new MongooseAdapter('MONGO_URI', { mongoose_options: 'here' }) +const adapter = new MongooseAdapter('MONGO_URI'); const adapter = new MongooseAdapter('MONGO_URI', { mongoose_options: 'here' }) ``` @@ -61,8 +58,7 @@ Opens a connection to mongoDB ### mongooseAdapter.setFiltered([enable]) -Switch adapter to (non)filtered state. -Casbin uses this flag to determine if it should load the whole policy from DB or not. +Switch adapter to (non)filtered state. Casbin uses this flag to determine if it should load the whole policy from DB or not. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -79,8 +75,7 @@ isFiltered determines whether the filtered model is enabled for the adapter. ### mongooseAdapter.setSynced([synced]) -SyncedAdapter: Switch adapter to (non)synced state. -This enables mongoDB transactions when loading and saving policies to DB. +SyncedAdapter: Switch adapter to (non)synced state. This enables mongoDB transactions when loading and saving policies to DB. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -91,8 +86,7 @@ This enables mongoDB transactions when loading and saving policies to DB. ### mongooseAdapter.setAutoAbort([abort]) -SyncedAdapter: Automatically abort on Error. -When enabled, functions will automatically abort on error +SyncedAdapter: Automatically abort on Error. When enabled, functions will automatically abort on error **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -103,8 +97,7 @@ When enabled, functions will automatically abort on error ### mongooseAdapter.setAutoCommit([commit]) -SyncedAdapter: Automatically commit after each addition. -When enabled, functions will automatically commit after function has finished +SyncedAdapter: Automatically commit after each addition. When enabled, functions will automatically commit after function has finished **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -127,30 +120,26 @@ SyncedAdapter: Sets current session to specific one. Do not use this unless you ### mongooseAdapter.getTransaction() ⇒ Promise.<Session> -SyncedAdapter: Gets active transaction or starts a new one. Transaction must be closed before changes are done -to the database. See: commitTransaction, abortTransaction +SyncedAdapter: Gets active transaction or starts a new one. Transaction must be closed before changes are done to the database. See: commitTransaction, abortTransaction **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) **Returns**: Promise.<Session> - Returns a session with active transaction ### mongooseAdapter.commitTransaction() ⇒ Promise.<void> -SyncedAdapter: Commits active transaction. Documents are not saved before this function is used. -Transaction closes after the use of this function. +SyncedAdapter: Commits active transaction. Documents are not saved before this function is used. Transaction closes after the use of this function. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) ### mongooseAdapter.abortTransaction() ⇒ Promise.<void> -SyncedAdapter: Aborts active transaction. All Document changes within this transaction are reverted. -Transaction closes after the use of this function. +SyncedAdapter: Aborts active transaction. All Document changes within this transaction are reverted. Transaction closes after the use of this function. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) ### mongooseAdapter.loadPolicyLine(line, model) -Loads one policy rule into casbin model. -This method is used by casbin and should not be called by user. +Loads one policy rule into casbin model. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -162,8 +151,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.loadPolicy(model) ⇒ Promise.<void> -Implements the process of loading policy from database into enforcer. -This method is used by casbin and should not be called by user. +Implements the process of loading policy from database into enforcer. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -174,8 +162,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.loadFilteredPolicy(model, [filter]) -Loads partial policy based on filter criteria. -This method is used by casbin and should not be called by user. +Loads partial policy based on filter criteria. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -187,9 +174,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.savePolicyLine(ptype, rule) ⇒ Object -Generates one policy rule ready to be saved into MongoDB. -This method is used by casbin to generate Mongoose Model Object for single policy -and should not be called by user. +Generates one policy rule ready to be saved into MongoDB. This method is used by casbin to generate Mongoose Model Object for single policy and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) **Returns**: Object - Returns a created CasbinRule record for MongoDB @@ -202,11 +187,7 @@ and should not be called by user. ### mongooseAdapter.savePolicy(model) ⇒ Promise.<Boolean> -Implements the process of saving policy from enforcer into database. -If you are using replica sets with mongo, this function will use mongo -transaction, so every line in the policy needs tosucceed for this to -take effect. -This method is used by casbin and should not be called by user. +Implements the process of saving policy from enforcer into database. If you are using replica sets with mongo, this function will use mongo transaction, so every line in the policy needs tosucceed for this to take effect. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -217,8 +198,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.addPolicy(sec, ptype, rule) ⇒ Promise.<void> -Implements the process of adding policy rule. -This method is used by casbin and should not be called by user. +Implements the process of adding policy rule. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -231,8 +211,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.addPolicies(sec, ptype, rule) ⇒ Promise.<void> -Implements the process of adding a list of policy rules. -This method is used by casbin and should not be called by user. +Implements the process of adding a list of policy rules. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -245,8 +224,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.removePolicy(sec, ptype, rule) ⇒ Promise.<void> -Implements the process of removing a list of policy rules. -This method is used by casbin and should not be called by user. +Implements the process of removing a list of policy rules. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -259,8 +237,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.removePolicies(sec, ptype, rules) ⇒ Promise.<void> -Implements the process of removing a policyList rules. -This method is used by casbin and should not be called by user. +Implements the process of removing a policyList rules. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -273,8 +250,7 @@ This method is used by casbin and should not be called by user. ### mongooseAdapter.removeFilteredPolicy(sec, ptype, fieldIndex, ...fieldValues) ⇒ Promise.<void> -Implements the process of removing policy rules. -This method is used by casbin and should not be called by user. +Implements the process of removing policy rules. This method is used by casbin and should not be called by user. **Kind**: instance method of [MongooseAdapter](#MongooseAdapter) @@ -288,9 +264,7 @@ This method is used by casbin and should not be called by user. ### MongooseAdapter.newAdapter(uri, [options], [adapterOptions]) -Creates a new instance of mongoose adapter for casbin. -Instead of constructor, it does wait for successfull connection to MongoDB. -Preferable way to construct an adapter instance, is to use this static method. +Creates a new instance of mongoose adapter for casbin. Instead of constructor, it does wait for successfull connection to MongoDB. Preferable way to construct an adapter instance, is to use this static method. **Kind**: static method of [MongooseAdapter](#MongooseAdapter) @@ -302,15 +276,12 @@ Preferable way to construct an adapter instance, is to use this static method. **Example** ```js -const adapter = await MongooseAdapter.newAdapter('MONGO_URI'); -const adapter = await MongooseAdapter.newAdapter('MONGO_URI', { mongoose_options: 'here' }); +const adapter = await MongooseAdapter.newAdapter('MONGO_URI'); const adapter = await MongooseAdapter.newAdapter('MONGO_URI', { mongoose_options: 'here' }); ``` ### MongooseAdapter.newFilteredAdapter(uri, [options]) -Creates a new instance of mongoose adapter for casbin. -It does the same as newAdapter, but it also sets a flag that this adapter is in filtered state. -That way, casbin will not call loadPolicy() automatically. +Creates a new instance of mongoose adapter for casbin. It does the same as newAdapter, but it also sets a flag that this adapter is in filtered state. That way, casbin will not call loadPolicy() automatically. **Kind**: static method of [MongooseAdapter](#MongooseAdapter) @@ -321,16 +292,12 @@ That way, casbin will not call loadPolicy() automatically. **Example** ```js -const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI'); -const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI', { mongoose_options: 'here' }); +const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI'); const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI', { mongoose_options: 'here' }); ``` ### MongooseAdapter.newSyncedAdapter(uri, [options], autoAbort) -Creates a new instance of mongoose adapter for casbin. -It does the same as newAdapter, but it checks wether database is a replica set. If it is, it enables -transactions for the adapter. -Transactions are never commited automatically. You have to use commitTransaction to add pending changes. +Creates a new instance of mongoose adapter for casbin. It does the same as newAdapter, but it checks wether database is a replica set. If it is, it enables transactions for the adapter. Transactions are never commited automatically. You have to use commitTransaction to add pending changes. **Kind**: static method of [MongooseAdapter](#MongooseAdapter) @@ -342,6 +309,5 @@ Transactions are never commited automatically. You have to use commitTransaction **Example** ```js -const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI'); -const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI', { mongoose_options: 'here' }); +const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI'); const adapter = await MongooseAdapter.newFilteredAdapter('MONGO_URI', { mongoose_options: 'here' }); ``` diff --git a/package.json b/package.json index 85b8122..31ddeff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "casbin-mongoose-adapter", - "version": "2.2.1", + "version": "2.2.2", "description": "Mongoose adapter for Casbin", "main": "src/adapter.js", "license": "Apache-2.0",