Git Product home page Git Product logo

json-datafile's Introduction

Librairie json-datafile

L'objectif de la librairie json-datafile est de proposer une micro BDD au format fichier JSON. L'idée est de pouvoir implémenter rapidement une couche de stockage dans une appli sans avoir à se brancher/créer une vraie BDD.

📜 How to Use

Import de la librairie

Dépendance Maven :

<dependency>
    <groupId>fr.forge.lib</groupId>
    <artifactId>json-datafile</artifactId>
    <version>2.0.0</version>
</dependency>

Interface Database

Exemple d'utilisation de l'inteface Database :

public class Service {

    private final Database<Model> modelDatabase;
    private Model model;

    /**
     * Initialisation d'une database pour l'objet Model
     */
    public Service() {
        this.modelDatabase = new JsonDatabase<>(Model.class, "fs/database/model.json");
        this.model = this.loadDatabase();
    }

    /**
     * Chargement de l'objet Model depuis la database
     */
    private Model loadDatabase() {
        try {
            return modelDatabase.load();
        } catch (JsonDatabaseException e) {
            log.error(e.getMessage());
        }
    }

    /**
     * Mise à jour de l'objet Model dans la database
     */
    private void syncDatabase() {
        try {
            this.modelDatabase.save(this.model);
        } catch (JsonDatabaseException e) {
            log.error(e.getMessage());
        }
    }
}

📋 Documentation interne

Publication de l'artifact dans le repo Github Packages

Le pipeline github actions est dispo ici : .github/workflows/publish-artifact.yml

Overview :

  • Build java via maven deploy
  • Nom de l'image : fr.forge.lib.json-datafile

Déploiement manuel de l'artifact sur Github Packages

# Set version to release version
mvn versions:set -DnewVersion=1.x

# Deploy to package registry
mvn clean deploy

# Set version to next snapshot version
mvn versions:set -DnewVersion=1.(x+1)-SNAPSHOT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.