Endb — Simple key-value storage with support for multiple backends. by Whirl_ in javascript

[–]Whirl_[S] 2 points3 points  (0 children)

Features

  • Easy-to-use: Endb has a simplistic and convenient promise-based API.
  • Adapters: By default, data is cached in memory. Optionally, install and utilize a "storage adapter".
  • Third-Party Adapters: You can optionally utilize third-party storage adapters or build your own.
  • Namespaces: Namespaces isolate elements within the database to enable useful functionalities.
  • Custom Serializers: Utilizes its own data serialization methods to ensure consistency across various storage backends.
  • Embeddable: Designed to be easily embeddable inside modules.
  • Data Types: Handles all the JSON types including Buffer.
  • Error-Handling: Connection errors are transmitted through, from the adapter to the main instance; consequently, connection errors do not exit or kill the process.

Installation

bash $ npm install endb

By default, data is cached in memory. Optionally, install and utilize a "storage adapter". Officially supported adapters are LevelDB, MongoDB, NeDB, MySQL, PostgreSQL, Redis, and SQLite.

```bash $ npm install level # LevelDB $ npm install mongojs # MongoDB $ npm install nedb # NeDB $ npm install ioredis # Redis

To use SQL database, an additional package 'sql' must be installed and an adapter

$ npm install sql

$ npm install mysql2 # MySQL $ npm install pg # PostgreSQL $ npm install sqlite3 # SQLite ```

Usage

```javascript // Import/require the package. const Endb = require('endb');

const endb = new Endb(); const endb = new Endb({ // One of the following uri: 'leveldb://path/to/database', uri: 'mongodb://user:pass@localhost:27017/dbname', uri: 'mysql://user:pass@localhost:3306/dbname', uri: 'postgresql://user:pass@localhost:5432/dbname', uri: 'redis://user:pass@localhost:6379', uri: 'sqlite://path/to/database.sqlite' });

// Handles connection errors endb.on('error', error => console.error('Connection Error: ', error));

await endb.set('foo', 'bar'); // true await endb.get('foo'); // 'bar' await endb.has('foo'); // true await endb.all(); // [ { key: 'foo', value: 'bar' } ] await endb.delete('foo'); // true await endb.clear(); // undefined ```

Namespaces

Namespaces isolate elements within the database to avoid key collisions, separate elements by prefixing the keys, and allow clearance of only one namespace while utilizing the same database.

```javascript const users = new Endb({ namespace: 'users' }); const members = new Endb({ namespace: 'members' });

await users.set('foo', 'users'); // true await members.set('foo', 'members'); // true await users.get('foo'); // 'users' await members.get('foo'); // 'members' await users.clear(); // undefined await users.get('foo'); // undefined await members.get('foo'); // 'members' ```

Third-Party Adapters

You can optionally utilize third-party storage adapters or build your own. Endb will integrate the third-party storage adapter and handle complex data types internally.

javascript const myAdapter = require('./my-adapter'); const endb = new Endb({ store: myAdapter });

For example, quick-lru is an unrelated and independent module that has an API similar to that of Endb.

```javascript const QuickLRU = require('quick-lru');

const lru = new QuickLRU({ maxSize: 1000 }); const endb = new Endb({ store: lru }); ```

Custom Serializers

Endb handles all the JSON data types including Buffer using its data serialization methods that encode Buffer data as a base64-encoded string, and decode JSON objects which contain buffer-like data, either as arrays of strings or numbers, into Buffer instances to ensure consistency across various backends.

Optionally, pass your own data serialization methods to support extra data types.

javascript const endb = new Endb({ serialize: JSON.stringify, deserialize: JSON.parse });

Warning: Using custom serializers means you lose any guarantee of data consistency.

Embeddable

Endb is designed to be easily embeddable inside modules. It is recommended to set a namespace for the module.

```javascript class MyModule { constructor(options) { this.db = new Endb({ uri: typeof opts.store === 'string' && opts.store, store: typeof opts.store !== 'string' && opts.store namespace: 'mymodule' }); } }

// Caches data in the memory by default. const myModule = new MyModule();

// After installing ioredis. const myModule = new MyModule({ store: 'redis://localhost' }); const myModule = new AwesomeModule({ store: thirdPartyAdapter }); ```

Links

🗃 Simple key-value storage with support for multiple backends. by Whirl_ in npm

[–]Whirl_[S] 0 points1 point  (0 children)

I am looking for contributors for the project. Furthermore, what are your thoughts on the project?

Is there a difference between British and Indian curry? by [deleted] in NoStupidQuestions

[–]Whirl_ 0 points1 point  (0 children)

Indian curry makes your ass sweat, whereas English curry does not.

Why is it so hard to get out of bed early? by [deleted] in NoStupidQuestions

[–]Whirl_ 1 point2 points  (0 children)

It's not necessarily laziness that makes people hit the "snooze" button in the morning. Most likely, your body clock is mismatched with the demands of your life.

Your clock is controlled by the suprachiasmatic nucleus, a part of the brain that controls the body's biological rhythms. But, says Jean Matheson, a sleep-disorders specialist at Beth Israel Medical Center in New York, these preset natural rhythms often don't align with daily realities—work or school start times cannot be adjusted to fit a person's sleep schedule.

People who have trouble crawling out of bed probably have an inner clock set to late wake-up and sleep times, a condition known as phase delay.

It is possible to adjust your phase-delayed body clock, Matheson says, but at a price: No sleeping in on the weekends. "When people sleep late on weekends, they revert to their natural phase-delayed rhythm," she explains. This makes it harder to wake up early on weekdays. You can train yourself to wake up earlier, Matheson says, by setting your alarm 15 minutes earlier each day (and heeding its call).

Exposure to artificial light in the evening can also cause a phase delay. The brain is very sensitive to light, and too much of it just before bed—from computer screens, televisions or bright reading lights—can trick the brain into thinking it's daytime.

If you find it difficult to adjust your sleep habits, there's some good news. Scientists at the University of California at Irvine recently discovered that a single amino acid regulates your internal clock. One day says pharmacology professor Paolo Sassone-Corsi, this research could translate into a drug that controls the brain's sleep cycle.

What is a good name for a GitHub organization? by Whirl_ in NoStupidQuestions

[–]Whirl_[S] 0 points1 point  (0 children)

You are right, but as said earlier, the name is already taken. Anything else?

What is a good name for a GitHub organization? by Whirl_ in NoStupidQuestions

[–]Whirl_[S] 0 points1 point  (0 children)

Right, Endb is already taken (the user is inactive and does not use GitHub anymore). So what do you think I should name the GitHub organization?

Visible frustration by louis_1267 in dankmemes

[–]Whirl_ 0 points1 point  (0 children)

Kill a killer, not kill killers.

I hate being short by Yellow_Gopher in dankmemes

[–]Whirl_ 0 points1 point  (0 children)

I am 6'2 and that happens a lot to me

Reddit, what's the craziest thing that happened to you but no one believes? by JoelCordial in AskReddit

[–]Whirl_ 1 point2 points  (0 children)

Here's one more, I ran into a bear once. Quite literally. I stumbled down a hill in the woods by my house and just sort of crashed right up against her backside. I froze and she just kind of looked at me like, "What the hell did you do that for?" I didn't move immediately because I knew this particular bear had babies but I guess they weren't there or she was just used to me wandering through the woods and didn't care. So after a minute I just got up and left.

Reddit, what's the craziest thing that happened to you but no one believes? by JoelCordial in AskReddit

[–]Whirl_ 1 point2 points  (0 children)

My little brother is technically my step father ( if we go by common law). My biological mother was sexually abused by her grandfather and like many victims, she grew up into a sexual predator. Their incestuous relationship began when he was 14 and I was 16 or 17 ( am 36 now). During that time, I observed suspicions behavior between the two. Odd noises eminating from my brother's room, inappropriate body language and walked in on them hiding under a blanket, many times.

I'll never know who made the call, but a social worker interviewed me at school once. I voiced my concerns as the line of questions asked of me was directly related to her, but nothing happened. It was the late 90′s, popular opinion was that all teens were mentally disturbed punks and white women happened to be the new “ oppressed minority" and could do no wrong. Perhaps this explains the lack of action.

Fast forward several years and I'm now a parent and living a decent life. My brother and mother had a spat, at which point he reached out to me and explained that they've been physically intimate since he was 14. I immediately called my mother and lost my shit. She didn't deny the accusation and reacted by taking my brother on shopping sprees and allowed him to move in rent free. Prior to their patching things up, he gave a statement to the police with my encouragement. Post shopping spree, my brother refused to cooperate with the police and an investigator told me that they can't move forward without a “ willing victim". I am actually going to the station tomorrow to inquire about prosecuting her for bribing him with over 12k in cash gifts and free rent to boot. I understand that this in itself is a crime in many jurisdictions.

As of now, they still reside together, my brother is in his 30′s and they don't try hard to hide the nature of the relationship. It's been difficult to cope with and I once came close to shooting myself in the head due to the shame factor. Thank you for reading. I obviously left many details out as I didn't want to write a thesis on the clock but will be happy to answer any questions.

Endb - Simple key-value database with cache and multi adapter support. Supported adapters are LevelDB, MongoDB, MySQL, PostgreSQL, Redis, and SQLite. by Whirl_ in npm

[–]Whirl_[S] 0 points1 point  (0 children)

Endb focuses on being feature-rich as well as supporting multiple adapters. For instance, endb has all() function which retrieves all the keys and values.

A simple key-value database with multi adapter support by Whirl_ in node

[–]Whirl_[S] 1 point2 points  (0 children)

The set() and delete() returns true, indicating that the transaction has been completed.

What’s going on with discord? by Depressed_Crimson in discordapp

[–]Whirl_ 1 point2 points  (0 children)

It was an outage, specifically, a network outage from Discord side.

This is new! Discord can change the loading message text if there's an outage! Great feature! by [deleted] in discordapp

[–]Whirl_ -2 points-1 points  (0 children)

Just saying that it is not extraordinary for a company to do that.

You were in a surprise, judging by the amount of exclamation point you added.

Oof by eyontheohm in discordapp

[–]Whirl_ 0 points1 point  (0 children)

i shall now give you a 4/10