Comments (4)
from jsoning.
I just use something like this:
const transformers = await db.get("transformers");
const transformerToRemove = "optimus prime";
await db.set(`transformers`, transformers.filter(transformer=> transformer !== transformerToRemove))
from jsoning.
Is anyone interested in implementing this feature resulting in a Hacktoberfest PR? ;)
from jsoning.
jsoning.prototype.remove = async function(key, callback) {
const array = await this.get(key);
return this.set(key, array.filter(item => !callback(item)))
};
await db.remove('jobs', (job) => {
return job.id === 'xxxxxxx';
});
jsoning.prototype.update = async function(key, callback) {
const array = await this.get(key);
return this.set(key, array.map(item => callback(item) || item))
};
await db.update('jobs', (job) => {
if(job.id === 'xxxxxxx') {
return {
...job,
...params,
}
}
return job;
});
from jsoning.
Related Issues (12)
- Exclude node_modules HOT 4
- Prototype Pollution Vulnerability HOT 4
- Typescript Declarations HOT 1
- set(key, value) does not read the DB from the file system and overwrites file system changes HOT 2
- Typescript: Push method value parameter type HOT 2
- async methods should be declared as returning Promise HOT 3
- `has` test doesn't exercise existing key case HOT 5
- db.math("money", "add", 200) not work HOT 1
- A jsoning question - PHP related ( although this IS a npm package ) - not to the language itself HOT 4
- suggestions HOT 3
- Add type parameter to Jsoning class HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsoning.