juicycleff / casbin-mongodb-adapter

Pure MongoDB adapter for Casbin
MIT License
9 stars 14 forks source link

Is not possible to use removeFilteredPolicy properly #16

Closed pverdile closed 1 year ago

pverdile commented 3 years ago

The removeFilteredPolicy creates a new object using the CasbinRule class,

https://github.com/juicycleff/casbin-mongodb-adapter/blob/793909c68f6ecf146021d3d3261b34b4792f95de/src/lib/adapter.ts#L222

which create a instance with the properties createdAt and updatedAt

https://github.com/juicycleff/casbin-mongodb-adapter/blob/793909c68f6ecf146021d3d3261b34b4792f95de/src/lib/casbin-rule.entity.ts#L28

providing a object which will use to in the deleteMany in the following format

{
 createdAt: '2021-06-18T20:47:52.585Z',
 updatedAt: '2021-06-18T20:47:52.585Z',
 ptype: 'p',
 v0: 'user',
 v1: 'pietro.verdile',
 v2: 1,
 v3: 'library',
 v4: 'systemTags',
 v5: 'eq;lib_60ccdfa5bc9e5400376a03ac'
}

This object never will match any document in MongoDB due the properties createdAt and updatedAt.