Introduction
Getting Started
App Config File
Entity Schemas
NoLang Script
NoLang Endpoints
Microservices
Storage
Documents / Storage
contents

Storage and Persistent

In NoLang, programmers don't have to write and implement several lines of code to store or persist data. It will be handled by NoLang itself.
Using $$storage we can configure how the entity persists its data.
For example, data of entity1 be saved in a file by a path :
{
	"$id": "entity1",
	"properties": {},
	"$$storage": {
		"adapter": "file",
		"path": "/entity1-data.json"
	}
}
For storing data in a MySQL database :
{
	"$id": "entity1",
	"properties": {},
	"$$storage": {
		"adapter": "mysql",
		"host": "127.0.0.1",
		"username": "root",
		"password": "****",
		"database": "db",
		"table": "table1"
	}
}
For persist data in MongoDB :
{
	"$$storage": {
		"adapter": "mongodb",
		"url": "mongodb://localhost:27017",
		"database": "app1",
		"id": "_id"
	}
}
Or even an inline non editable json data :
{
	"$$storage": {
		"adapter": "inline",
		"data": [
			{
				"id": 1,
				"name": "Reza"
			},
			{
				"id": 2,
				"name": "Ahmad"
			}
		]
	}
}
If there is not any data, using faker adapter generates mock data for the schema :
{
	"$$storage": {
		"adapter": "faker",
		"count": 100
	}
}
In NoLang there is several adapters for storing data of entities such as :
    list
  • mongodb
  • mysql
  • csv
  • postgres
  • file
  • memory
  • faker
  • json
  • inline
  • default
  • ,...
It is possible to set storage configuration in the config file and don't set for each schema, or in every schema we can use adapter by value default and add the schema's specific configuration