trashable | make promises cancellable and garbage | Reactive Programming library
kandi X-RAY | trashable Summary
kandi X-RAY | trashable Summary
A wrapper to make promises cancellable and garbage collectable. See how this relates to React below and use trashable-react to make your React components garbage collectable.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of trashable
trashable Key Features
trashable Examples and Code Snippets
Community Discussions
Trending Discussions on trashable
QUESTION
I'm building the backend of my e-shop using Sequelize. I have defined models for clients
, products
, orders
, etc. I want any instance of these models to be "trashable", i.e. just like deleted instances, I want trashed instances not to appear in the results of calls to .findAll()
, .gets()
or even .findAll({ include: [{ model: }]
. But I still want to be able to query those trashed instances (and restore them eventually).
The solution I'm considering is adding a .status
property to my models (ENUM('active', 'trashed')
), and then adding a beforeFind
hook to all my models to filter out instances that are not active
unless the query is explicitly searching for id(s) or trashed
items.
I worry about the potential complexity of the queries passed to my beforeFind
hook, though. How to detect what the queries are searching for and how should they be modified to filter-out trashed items? And there are probably other shortcomings to this solution I didn't even consider…
Before giving implementation a try, I wanted to know if others had given this pattern a try, how they did it and what difficulties they faced. Thanks :-)
...ANSWER
Answered 2017-May-10 at 08:27Are you looking for the paranoid
option?
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install trashable
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page