Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Add using Schema to the package #50

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Node.js Package NPM
name: Publish the package to NPM

# on:
# push:
# paths:
# - 'package.json'
on:
release:
types:
Expand Down
7 changes: 4 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.git/
.github
.github/
Docs/
test/
content/
content/
node_modules
package-lock.json
.vscode
37 changes: 16 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
MIT License

Copyright (c) 2023 Mark Maher Ewida
Copyright (c) 2023 Mark Maher

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"jsonverse"), to deal in the jsonverse without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the jsonverse, and to
permit persons to whom the jsonverse is furnished to do so, subject to
the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

1. The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the jsonverse.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

2. The jsonverse is provided "as is," without warranty of any kind,
express or implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose, and
non-infringement. In no event shall the authors or copyright
holders be liable for any claim, damages, or other liability,
whether in an action of contract, tort, or otherwise, arising from,
out of, or in connection with the jsonverse or the use or other
dealings in the jsonverse.

For more details, please contact us:
[Email](mailto:marco5dev@outlook.com) : `marco5dev@outlook.com`
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

jsonVerse is a lightweight JSON-based database package for Node.js. It provides a simple interface to store, retrieve, and manage data using JSON files.

[![Node.js Package NPM](https://github.com/Marco5dev/jsonverse/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/Marco5dev/jsonverse/actions/workflows/npm-publish.yml)
[![Build](https://github.com/Marco5dev/jsonverse/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/Marco5dev/jsonverse/actions/workflows/npm-publish.yml)
[![NPM Version](https://img.shields.io/npm/v/jsonverse.svg)](https://www.npmjs.com/package/jsonverse)
[![NPM Downloads](https://img.shields.io/npm/dt/jsonverse.svg)](https://www.npmjs.com/package/jsonverse)
[![Github Repo Size](https://img.shields.io/github/repo-size/Marco5dev/jsonverse.svg)](https://github.com/Marco5dev/jsonverse)
[![LICENSE](https://img.shields.io/npm/l/jsonverse.svg)](https://github.com/Marco5dev/jsonverse/blob/master/LICENSE)
[![Contributors](https://img.shields.io/github/contributors/Marco5dev/jsonverse.svg)](https://github.com/Marco5dev/jsonverse/graphs/contributors)
[![Commit](https://img.shields.io/github/last-commit/Marco5dev/jsonverse.svg)](https://github.com/Marco5dev/jsonverse/commits/master)

## Introduction

Expand Down
65 changes: 0 additions & 65 deletions content/docs/1.3.0/Getting Started/installation.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ toc: true

The `jsonverse` class provides methods for logging messages to both the console and log files.

## `logToConsoleAndFile(message)` Method
## logToConsoleAndFile(message) Method

The `logToConsoleAndFile(message)` method logs a message to both the console and the log file.

Expand All @@ -26,7 +26,7 @@ jsonverse.logToConsoleAndFile('This is a log message.');

Use this method to log messages that should be displayed in the console and recorded in a log file.

## `logError(message)` Method
## logError(message) Method

The `logError(message)` method logs an error message to both the console and the log file.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ menu:
identifier: "model() Method-bcb72a438a345fab613f8287dde75ce9"
weight: 130
toc: true
beta: true
---

The `model()` method creates and returns a model instance for defining and interacting with data models.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ menu:
identifier: "Constructor-98c524aa263d84d9c0010b6477669a99"
weight: 160
toc: true
beta: true
---

The constructor initializes a `Model` instance with the specified data name and schema definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ menu:
identifier: "delete() Method-487da9090ae1d34aec48a3bae10a8b5c"
weight: 180
toc: true
beta: true
---

The `delete()` method allows you to delete data from the database using a `Model` instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ menu:
identifier: "find() Method-57bb54b13b29dac68dcacc12c465221c"
weight: 200
toc: true
beta: true
---

The `find()` method allows you to search for data in the database using a `Model` instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ menu:
identifier: "save() Method-85fa0aaf8ac16b1318330df9bd1cc37b"
weight: 170
toc: true
beta: true
---

The `save()` method allows you to save data to the database using a `Model` instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ menu:
identifier: "update() Method-353bca8f38b1ee5bc699b38ccf67ee68"
weight: 190
toc: true
beta: true
---

The `update()` method allows you to update data in the database using a `Model` instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ toc: true

Data backup and restore are crucial operations to ensure data integrity and disaster recovery in jsonverse. This section explains how to create data backups and restore data from backups.

1. **Create Data Backup**:
## 1. **Create Data Backup**:

To create a data backup, you can use the `backupCreate` method of the jsonverse instance. Here's an example:

Expand All @@ -35,7 +35,7 @@ Data backup and restore are crucial operations to ensure data integrity and disa

This code creates a backup of the data associated with the specified `dataName`.

2. **Restore Data from Backup**:
## 2. **Restore Data from Backup**:

To restore data from a backup, you can use the `backupRestore` method of the jsonverse instance. Here's an example:

Expand All @@ -55,21 +55,21 @@ Data backup and restore are crucial operations to ensure data integrity and disa

This code restores data from the specified backup file.

3. **Data Backup Cleanup**:
## 3. **Data Backup Cleanup**:

To manage disk space and keep only necessary backups, you can implement a backup cleanup process. This process can be automated to delete old backups based on your retention policy.

4. **Backup File Naming Convention**:
## 4. **Backup File Naming Convention**:

It's a good practice to follow a consistent naming convention for backup files. In the example above, the backup file name includes the data name and a timestamp to identify the backup's contents and creation time.

- Example Backup File Name: `myData_20230101120000.json`

5. **Backup Frequency**:
## 5. **Backup Frequency**:

Determine how often you need to create backups based on your data's criticality and update frequency. Common backup frequencies include daily, weekly, or even real-time backups for mission-critical data.

6. **Backup Location**:
## 6. **Backup Location**:

Store backups in a secure location, separate from your primary data. Cloud storage and off-site backups provide additional protection against data loss.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ toc: true

Data security is a top priority in jsonverse, and it offers built-in data encryption and decryption features to protect sensitive information. This section explains how to encrypt and decrypt data using jsonverse.

1. **Encrypt Data**:
## 1. **Encrypt Data**:

To encrypt sensitive data, you can use the `encrypt` method of the jsonverse instance. Here's an example:

Expand All @@ -31,7 +31,7 @@ Data security is a top priority in jsonverse, and it offers built-in data encryp

In this code, we encrypt the `dataToEncrypt` object using a secret key. The result, `encryptedData`, contains the encrypted data.

2. **Decrypt Data**:
## 2. **Decrypt Data**:

To decrypt encrypted data, you can use the `decrypt` method of the jsonverse instance. Here's an example:

Expand All @@ -46,23 +46,23 @@ Data security is a top priority in jsonverse, and it offers built-in data encryp

This code decrypts the `encryptedData` using the same secret key, resulting in the original data.

3. **Secret Key Management**:
## 3. **Secret Key Management**:

The secret key used for encryption and decryption should be kept secure. It's essential to implement strong key management practices, such as using key vaults or hardware security modules (HSMs), to protect your keys.

4. **Data Sensitivity**:
## 4. **Data Sensitivity**:

Identify the data that requires encryption based on its sensitivity. Sensitive data may include passwords, personal information, or confidential documents.

5. **Encryption Algorithms**:
## 5. **Encryption Algorithms**:

jsonverse uses the AES (Advanced Encryption Standard) algorithm for data encryption, a widely accepted and secure encryption standard.

6. **Data Security Best Practices**:
## 6. **Data Security Best Practices**:

Follow best practices for data security, including access control, encryption at rest, and data masking, to protect sensitive information throughout its lifecycle.

7. **Compliance and Regulations**:
## 7. **Compliance and Regulations**:

Consider compliance requirements and industry regulations that may dictate data encryption practices, especially when handling sensitive data like healthcare or financial information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ menu:
identifier: "Data Models-e895bff170eeccaa93b0bf7c3a259469"
weight: 50
toc: true
beta: true
---

Data models define the structure and schema of your data in jsonverse. When you create a data model, you specify the fields and their data types. This section explains how to define and work with data models.

1. **Define a Data Model**:
## 1. **Define a Data Model**:

To define a data model, create an object that describes the schema. Here's an example:

Expand All @@ -31,7 +32,7 @@ Data models define the structure and schema of your data in jsonverse. When you

In this example, we define a data model for a user with fields like username, email, age, and active. The data types (String, Number, Boolean) indicate the expected type of each field.

2. **Create a Model Instance**:
## 2. **Create a Model Instance**:

To work with a data model, you need to create an instance of it. Use the jsonverse API to create a model instance based on your schema:

Expand All @@ -41,7 +42,7 @@ Data models define the structure and schema of your data in jsonverse. When you

In this example, we create a model instance for our User data model.

3. **Data Operations with Models**:
## 3. **Data Operations with Models**:

Once you have a model instance, you can perform various data operations like saving, updating, and querying data. Here are some common operations:

Expand Down Expand Up @@ -107,11 +108,11 @@ Data models define the structure and schema of your data in jsonverse. When you

These operations allow you to interact with your data using the defined data model.

4. **Data Validation**:
## 4. **Data Validation**:

jsonverse performs basic data validation based on your schema when saving data. If the data doesn't match the schema, it will throw an error.

5. **Model Usage**:
## 5. **Model Usage**:

You can use your defined data models across your application to ensure consistency in your data structure.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ toc: true

Data transformation is a fundamental concept in jsonverse, allowing you to modify data as needed. This section explains how to perform data transformation using jsonverse.

1. **Transform Data**:
## 1. **Transform Data**:

To transform data, you can use the `transformData` method of the jsonverse instance. Here's an example:

Expand All @@ -42,27 +42,27 @@ Data transformation is a fundamental concept in jsonverse, allowing you to modif

In this code, we define a transformation function that modifies each data item as needed. The `transformData` method applies this function to the data associated with the specified `dataName`.

2. **Transformation Logic**:
## 2. **Transformation Logic**:

Define your transformation logic based on your specific requirements. You can add, remove, or modify fields within each data item.

3. **Use Cases**:
## 3. **Use Cases**:

Data transformation is useful for various scenarios, including data cleaning, normalization, or preparing data for specific operations.

4. **Data Integrity**:
## 4. **Data Integrity**:

Ensure that your transformation logic maintains data integrity and consistency. Validate and test the transformed data to avoid unintended issues.

5. **Transformation Frequency**:
## 5. **Transformation Frequency**:

Determine how often you need to apply data transformations based on your data update frequency and business needs.

6. **Data Transformation as a Middleware**:
## 6. **Data Transformation as a Middleware**:

Consider using data transformation as a middleware step between data retrieval and data processing to adapt data to your application's requirements.

7. **Backup Before Transformation**:
## 7. **Backup Before Transformation**:

Before performing significant data transformations, create a backup to ensure you can revert to the original data if needed.

Expand Down
Loading