Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mshahzadtariq/persistable_mongoid
Persist Deleted Records for Mongoid Soft delete functionality for Mongoid ORM so you may recover records at later stage.
https://github.com/mshahzadtariq/persistable_mongoid
gem mongodb orm persistable ruby ruby-on-rails
Last synced: about 4 hours ago
JSON representation
Persist Deleted Records for Mongoid Soft delete functionality for Mongoid ORM so you may recover records at later stage.
- Host: GitHub
- URL: https://github.com/mshahzadtariq/persistable_mongoid
- Owner: mshahzadtariq
- License: mit
- Created: 2015-06-01T08:24:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-30T11:01:52.000Z (over 9 years ago)
- Last Synced: 2023-07-31T13:45:42.138Z (over 1 year ago)
- Topics: gem, mongodb, orm, persistable, ruby, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 211 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
Awesome Lists containing this project
README
= Mongoid Persistable
Persist Deleted Records for Mongoid
Soft delete functionality for Mongoid ORM so you may recover records at later stage.== Installation
Add following line to your Gemfile
gem 'persistable_mongoid'
or
gem 'persistable_mongoid', git: 'https://github.com/mshahzadtariq/persistable_mongoid'
or
gem install persistable_mongoid
And include this module to the model for which you want to enable soft delete and recovery feature
class MyModel
include Mongoid::Document
include MST::Persistable
......
end
and that is all.== Usage
Persist sensitive data with options to recover data.
To persist record, call destroy method on object. It will not delete record from database but persist that so you can recover it in the future if required.
object.destroy
It also has two scopesonly_deleted: Fetch only deleted records of that particular model
e.gModel.only_deleted
with_deleted: Fetch all records of that particular model including deleted records
e.gModel.with_deleted
To recover records, call recover method on object
Model.only_deleted.first.recover
To permanently delete record from system/database, call delete method
object.delete
== Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request