Galaxy-Flatfile
About
It is a flatfile storage library, developed by Galaxy. If you have questions or problems do not hesitate to contact us. Support
Usage
- First of all, before you start using the library, you must install it. Download
- Once downloaded you can start using it. Below you will find basic examples of how to use it.
Methods
Flatfile(file, directory)
- To create a new flatfile
-
file (String)
- The file name -
directory (Path)
- The directory
Flatfile#delete(file)
- To delete a file
-
file (String)
- The file name
Flatfile#add(key, value)
- Add data to a path
-
key (String)
- The data path -
value (String, Integer, Boolean, Array)
- The data value
Flatfile#rem(key)
- Remove data from a path
-
key (String)
- The data path
Flatfile#getKey(key)
- Get data from path
-
key (String)
- The data path
Flatfile#getSize(key)
- Get data path size
-
key (String)
- The data path
Example
const flatfile = require('simple-flatfile');
const file = new flatfile("users", __dirname);
if (!file.get("Users")){
file.add("Users", {});
file.add("Users.Alfreado", 60);
file.add("Users.Lucas", 40);
}
console.log("Users: " + file.getKey("Users"));
console.log("Users amount: " + file.getSize("Users"));
if (file.getKey("Users.Alfreado") > 80)){
file.add("Users.Alfreado", 0);
console.log("The level of Alfreado has been reset because he reached the maximum");
}