
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
nosql-json-database
Advanced tools
NoSQL JSON Database is a quick setup database for node and the browser that can be delightfully paired with any javascript testing framework.
nosql-json-database
is available on npm. To install it, type:
$ npm install --save-dev nosql-json-database
This module aims to help simplify the use of file modules using fs and path whenever developing an application that needs a database but you just don't want to use a standard database due to the long setup or for any other reason.
This module uses JSON files to store database documents and files. This was designed to be a simple node-js module to assist during the development of applications temporarily, or even during the designing or testing of an application. The application can be useful in multiple backend areas and offers some useful methods such as populate to allow for complex no-sql data structures to be implemented.
import Container
from the package folder and use to create the container for the database
import { Container } from "nosql-json-database";
const database = new Container();
const usersCollection = database.createCollection("users");
You can specify the location where all the database files would be contained
import { Container } from "nosql-json-database";
import path from "path";
const location = path.join(__dirname, "/");
const database = new Container(location);
It is recommended to specify the type as a model basis for the data to be contained this would help in intellisence and also when performing operations
import { Container } from "nosql-json-database";
type Users = {
name: string;
age: number;
email: string;
}
const database = new Container();
const usersCollection = database.createCollection<Users>("users");
import { Container } from "nosql-json-database";
type Users = {
name: string;
age: number;
email: string;
}
const database = new Container();
const usersCollection = database.createCollection("users");
usersCollection.addOne({
email: "joe@test.com",
age: 23,
name: "joe",
});
In addition to storing the data provided, an _id along with createdAt and updatedAt information is
added to the newly inserted document.
The _id is generated from using uuid
import { Container } from "nosql-json-database";
type Users = {
name: string;
password: string;
email: string;
}
const database = new Container();
const usersCollection = database.createCollection("users");
usersCollection.addOne({
email: "daniel@test.com",
password: "daniel1",
name: "daniel",
});
const response = usersCollection.find();
console.log(response);
// [
// {
// _id: 'json://users.be72b673-3f7c-4315-bbe0-a7311bf591d0',
// email: 'daniel@gmail.com',
// name: 'daniel',
// password: 'daniel1',
// createdAt: '2024-01-17T21:22:06.532Z',
// updatedAt: '2024-01-17T21:22:06.534Z'
// }
// ]
A document can be populated by specifying the field to be populated. The JSON database would handle the matching of the collections
import { Container } from "nosql-json-database";
type Users = {
name: stringl;
password: string;
email: string;
}
type Posts = {
title: string;
user: string;
body: string;
}
type Comments = {
postId: string;
userId: string;
text: string;
}
const database = new Container();
const users = database.createCollection<Users>("users");
const post = database.createCollection<Posts>("posts");
const comment = database.createCollection<Comments>("comments");
const newUser = usersCollection.addOne({
email: "joe@test.com",
name: "joe davis",
password: "joe1"
});
const newPost = postCollection.addOne({
user: newUser._id,
title: "test case post title",
body: "test case body 2",
});
const newComment = commentCollection.addOne({
postId: newPost._id,
userId: newUser._id,
text: "comment case",
});
console.log(comment.findAndPopulate(["postId", "userId"]));
// [
// {
// _id: 'json://comments.8a82370e-11e9-4514-a04f-bda2d30938fa',
// postId: {
// _id: 'json://posts.b1b3bf21-631d-4065-88b0-3b1b06983837',
// user: 'json://users.ba8febaf-0df2-4df4-afb7-4b3862293255',
// title: 'test case post title',
// body: 'test case body 2',
// createdAt: '2024-01-17T21:31:30.746Z',
// updatedAt: '2024-01-17T21:31:30.746Z'
// },
// userId: {
// _id: 'json://users.ba8febaf-0df2-4df4-afb7-4b3862293255',
// email: 'joe@gmail.com',
// password: 'joe1',
// name: 'joe davis',
// createdAt: '2024-01-17T21:31:30.744Z',
// updatedAt: '2024-01-17T21:31:30.745Z'
// },
// text: 'comment case',
// createdAt: '2024-01-17T21:31:30.747Z',
// updatedAt: '2024-01-17T21:31:30.747Z'
// }
// ]
MIT
FAQs
package for building simple nosql databases using json files
The npm package nosql-json-database receives a total of 6 weekly downloads. As such, nosql-json-database popularity was classified as not popular.
We found that nosql-json-database demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.