Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/milo123459/vstore

VStore - The most lenient way of saving data.
https://github.com/milo123459/vstore

tslib typescript vstore

Last synced: 2 months ago
JSON representation

VStore - The most lenient way of saving data.

Awesome Lists containing this project

README

        

# ⚡ **VStore** - **The most lenient way of saving data**

**If you want to support, you can ⭐ the [repo](https://github.com/Milo123459/VStore)!**

**FAQ**

> Where is data stored?

Data is stored in a folder named `store` located in the current CWD.

> What's the point?

To make data syncing easy.

> Does it work with TypeScript

It's written in TypeScript, so yes.

**Code examples**

Examples are written in JavaScript

**Setting up stuff**

```js
// Lets require the module!
const { VStore } = require("vstorejs");
//or
import { VStore } from "vstorejs";
// Create a store, we have to use
const Name = new VStore({
name: `Name`, // Required
memoryCache: true, // Defaults to false, if you want it enabled, set it as true
json: true, // Defaults to false, if you want it enabled, set it as true
});
// Note, to actually save data you need to have atleast one of the db methods active.
```

**Setting data**

```js
const Instance = Name.instance({
// list your properties here....
name: `john`, // Grabs type of the property
sirname: `doe`, // Grabs the type of the property
fullname: `{name} {sirname}`, // Allows you to replace strings automatically with this.properties, powered by cjays
}); // properties are optional
const Model = Instance.create({
name: `peter`,
sirname: `jeff`,
});
// If you don't specify something when creating the model, it will default to the value. Example is when you add name and sirname but not fullname, fullname would be: 'peter jeff'

const Model2 = Instance.create(); // The properties on this would be:
/**
* name: 'john',
* sirname: 'doe',
* fullname: 'john doe'
*
*/

const Model3 = Instance.create({
MyCustomProperty: `this isn't listed in the instance`,
});
// Properties on this would be:
/**
* name: 'john',
* sirname: 'doe',
* fullname: 'john doe',
* MyCustomProperty: 'this isn't listed in the instance'
*/
});
```

**Deleting data**

```js

Model.delete();
// or
Name.delete({/* search for things here */ }, index?); // this will call the search method, if you don't specify the index it'll default to 0, it takes in a number!
```

**Updating data**

```js
Model.update({ myNewProperty: "hello" });
```

**Features**

- Temporary JSON storage in the `store` directory
- Memory cache

**Search data**

```js
Name.search({ fullname: "john doe" }); // returns an array of items containing documents with fulllname as johndoe
```

**Dependencies**

- [cjays](https://npm.im/cjays)
- [lodash.defaults](https://npm.im/lodash.defaults)
- [nanoid](https://npm.im/nanoid)

**Examples**

You can find examples in the github repositors, in the examples directory.

# Planned features

Name is an instance of VStore.

```js
Name.duplicate({ searchData }, index?); // returns an instance of a model with duplicated data
Name.update({ serchData }, { newParams }, index?) // updates a model
```

Support for:

Template: DB_NAME (PLANNED_VERSION_TO_RELEASE)

Example:

MyCoolDB (V4)
^ This means that we plan to add support for MyCoolDB in Version 4 of VStore

- Postgres (V3.2)
- MongoDB (V1.1)
- Redis (V2)
- SQLite (V3)
- Quick.DB (V1.2) (I've been requested to add this like 4 times so here you go :( )

# Contributing

- Fork this repo
- Clone the forked repo
- CD into the directory
- git checkout -b my-cool-feature
- Write some code
- git add .
- git commit -m "i want to add a feature"
- Go to https://github.com/Milo123459/vstore/pulls and create a pull and select your branch