Skip to content

Commit

Permalink
chore: bump to 2.2.2 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan authored Sep 15, 2020
1 parent 504e356 commit 7432881
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 60 deletions.
84 changes: 25 additions & 59 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ Implements a policy adapter for casbin with MongoDB support.
<a name="new_MongooseAdapter_new"></a>

### 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 |
Expand All @@ -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' })
```
<a name="MongooseAdapter+_open"></a>

Expand All @@ -61,8 +58,7 @@ Opens a connection to mongoDB
<a name="MongooseAdapter+setFiltered"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -79,8 +75,7 @@ isFiltered determines whether the filtered model is enabled for the adapter.
<a name="MongooseAdapter+setSynced"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -91,8 +86,7 @@ This enables mongoDB transactions when loading and saving policies to DB.
<a name="MongooseAdapter+setAutoAbort"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -103,8 +97,7 @@ When enabled, functions will automatically abort on error
<a name="MongooseAdapter+setAutoCommit"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -127,30 +120,26 @@ SyncedAdapter: Sets current session to specific one. Do not use this unless you
<a name="MongooseAdapter+getTransaction"></a>

### mongooseAdapter.getTransaction() ⇒ <code>Promise.&lt;Session&gt;</code>
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 doneto the database. See: commitTransaction, abortTransaction

**Kind**: instance method of [<code>MongooseAdapter</code>](#MongooseAdapter)
**Returns**: <code>Promise.&lt;Session&gt;</code> - Returns a session with active transaction
<a name="MongooseAdapter+commitTransaction"></a>

### mongooseAdapter.commitTransaction() ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)
<a name="MongooseAdapter+abortTransaction"></a>

### mongooseAdapter.abortTransaction() ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)
<a name="MongooseAdapter+loadPolicyLine"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -162,8 +151,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+loadPolicy"></a>

### mongooseAdapter.loadPolicy(model) ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -174,8 +162,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+loadFilteredPolicy"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -187,9 +174,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+savePolicyLine"></a>

### mongooseAdapter.savePolicyLine(ptype, rule) ⇒ <code>Object</code>
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 policyand should not be called by user.

**Kind**: instance method of [<code>MongooseAdapter</code>](#MongooseAdapter)
**Returns**: <code>Object</code> - Returns a created CasbinRule record for MongoDB
Expand All @@ -202,11 +187,7 @@ and should not be called by user.
<a name="MongooseAdapter+savePolicy"></a>

### mongooseAdapter.savePolicy(model) ⇒ <code>Promise.&lt;Boolean&gt;</code>
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 mongotransaction, so every line in the policy needs tosucceed for this totake effect.This method is used by casbin and should not be called by user.

**Kind**: instance method of [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -217,8 +198,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+addPolicy"></a>

### mongooseAdapter.addPolicy(sec, ptype, rule) ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -231,8 +211,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+addPolicies"></a>

### mongooseAdapter.addPolicies(sec, ptype, rule) ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -245,8 +224,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+removePolicy"></a>

### mongooseAdapter.removePolicy(sec, ptype, rule) ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -259,8 +237,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+removePolicies"></a>

### mongooseAdapter.removePolicies(sec, ptype, rules) ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -273,8 +250,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter+removeFilteredPolicy"></a>

### mongooseAdapter.removeFilteredPolicy(sec, ptype, fieldIndex, ...fieldValues) ⇒ <code>Promise.&lt;void&gt;</code>
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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -288,9 +264,7 @@ This method is used by casbin and should not be called by user.
<a name="MongooseAdapter.newAdapter"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -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' });
```
<a name="MongooseAdapter.newFilteredAdapter"></a>

### 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 [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -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' });
```
<a name="MongooseAdapter.newSyncedAdapter"></a>

### 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 enablestransactions for the adapter.Transactions are never commited automatically. You have to use commitTransaction to add pending changes.

**Kind**: static method of [<code>MongooseAdapter</code>](#MongooseAdapter)

Expand All @@ -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' });
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 7432881

Please sign in to comment.