Skip to content

Milo123459/vstore

Repository files navigation

VStore - The most lenient way of saving data

If you want to support, you can ⭐ the repo!

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

// 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

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

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

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

Features

  • Temporary JSON storage in the store directory
  • Memory cache

Search data

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

Dependencies

Examples

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

Planned features

Name is an instance of VStore.

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

About

VStore - The most lenient way of saving data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published