jonschlinkert / data-store Goto Github PK
View Code? Open in Web Editor NEWEasily get, set and persist config data. Fast. Supports dot-notation in keys. No dependencies.
Home Page: https://github.com/jonschlinkert
License: MIT License
Easily get, set and persist config data. Fast. Supports dot-notation in keys. No dependencies.
Home Page: https://github.com/jonschlinkert
License: MIT License
https://github.com/jonschlinkert/data-store/blob/master/index.js#L392
This line:
const split = str => str.split(/(?<!\\)\./).map(strip);
Throws an error:
/redacted_path/node_modules/data-store/index.js:392
const split = str => str.split(/(?<!\\)\./).map(strip);
^
SyntaxError: Invalid regular expression: /(?<!\\)\./: Invalid group
at split (/redacted_path/node_modules/data-store/index.js:392:26)
at get (/redacted_path/node_modules/data-store/index.js:433:7)
at Store.has (/redacted_path/node_modules/data-store/index.js:148:19)
at /redacted_path/redacted_file.js:10:15
at Array.forEach (<anonymous>)
at Object.<anonymous> (/redacted_path/redacted_file.js:9:11)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
Changed it to:
const split = str => str.split(/(?!\\)\./).map(strip);
And it hasn't errored yet. I don't know if my fix will break anything though.
Hi, im using this package to create a discord bot i want to save the id's of all the pepole in a server, and assign a value to each of them, there are 6800 users in the server, and store is not persisting, even if i use, store.save(); im using heroku to have my bot, and i created a folder and set the cwd there. But still dosn't work, what im doing wrong?
I used data-store for a while now, and it worked well until i tried to store something from another folder, it just wont save no matter if i use .load() or .save(), the thing is sometimes it saves sometimes it doesn't and i checked its not because of my code. Ive double checked, the path is correct
Hi, is there a feature that allows you retrieve data set into the store from another js file? Or can you only read data set into the store from the same file.
I have a variable name 'symbol' which content crypto's symbol (Exp: DIA)
But when I use ${symbol}
an error 'Property assignment expected' appears. Here is my code:
store.set(`${id_user}`, {
`${symbol}`: {
price_set: ctx.state.price_set,
percent: ctx.state.percent,
status: ctx.state.status
}
}
);
What I should do to have data in JSON file storage like below???
{
"844827665": {
"DIA": {
"price_set": 1.8223378037209135,
"percent": "10",
"status": "up"
}
}
}
Tks for reading my issue. Have a good day, sir
or to do it as data-store-cli
? it may be useful for verb and for me
/cc @jonschlinkert
If I include a store as follows I get a Type Error about the class constructor (node v8.12)
const store = require('data-store')('my-store')
// TypeError: Class constructor Store cannot be invoked without 'new'
const Store = require('data-store')
const store = new Store('my-store')
// works
Maybe it would be best to export a function instead of the class?
module.exports = function(name, options, defaults) {
return new Store(name, options, defaults)
}
hi,
i am trying to store with a key containing a dot mark, something like this:
users.set('a.b', 'c')
but in the store the key is separated, like this:
"a": { "b": "c" }
can someone please explain me the right way to get my key not separated?
thankes
i do :
store.clear();
store.set('players', []);
store.load()
which deletes storage and only {} is left, why?
Because .has
won't return true when dot notation is used if key
value is null
or undefined
value on the data store and that values are possible case for stores/DBs/etc.
Hi!
I see that v4.1.0 hasn't been published on npm. Are there any issues preventing this new minor release?
code snippet:
if (!store.hasOwn('players')) {
store.set('players', []);
}
store.load();
let players = store.get('players');
let timer = null;
let cnt = (players.length > 0);
see: #25
Am I correct in thinking that .get() just returns the values stored in memory? If there is two separate instances of your store, how do you update them to the values stored in the file? Seems like I have to create a new instance of the store right before I run .get().
@jonschlinkert will you add me as an NPM owner so I can publish 4.1.0
. Thanks!
Given the case I call store.set with no value, the key-value pair will be removed from the json file but will remain as key-undefined in memory. Hence Object.keys remains to contain the key only until the file is being read again.
It would be nice to have this be consistent instead.
Please, it would be great to be possible to re-load the cache, or set it to something, becouse i edit the json file and the cache doesn't get updated.
Previously, I've used the package and it used to work fine but yesterday suddenly data-store wouldn't read all the data in the JSON file. If you log the data, it returns an empty object even if the file has data in it.
Is there any work around for this?
I've tried using debouce: 0
in the parameters when creating the store. I've also tried creating a class that extends Store
that every method calls .load()
but neither that works.
I would appreciate if it's fixed, I really use this package and is really useful.
Please pardon the silly issue, but I'm having trouble finding release notes for data-store, looking to understand the changes in 4.0.0 before I upgrade
I am trying to store data with data store and then read with another file, but whenever I try to read it reverts the data to old data. I have tried both with the save() function and without, same issue all the time.
Probably want to use alternative at below as this is deprecated since 4.0
Line 89 in bd96ee9
https://nodejs.org/api/util.html#util_util_isobject_object
Looks like you want a plain Object checker? Like ironically your package
Probably want to use alternative at below as this is deprecated since 4.0
Line 89 in bd96ee9
https://nodejs.org/api/util.html#util_util_isobject_object
Looks like you want a plain Object checker? Like this
Hi
I want to delete only one object of the array, like this :
{ bars: [ {bar: 'baz', bar2: 'baz2', } ] }
It is possible?
Thanks!
I want to remove element from data store and I am using typescript. When i try to delete using del method, I get error
"Property 'del' does not exist on type 'DataStore'.ts(2339)"
Any idea how to get it working?
store.get() without parameters doesn't work in version 3.0 but works in 1.0
In documentation is example without parameters.
I would like the option to create a lock file when the data-store is being synchronized. I understand this can cause slow-down so it would be off by default.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.