# Archiviare e leggere dati con il database NoSQL integrato

> Inserisci e interroga documenti con NOSQL() ed esponili tramite azioni, senza installare alcun database.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: it
Content-SHA256: 3025ff932e9d49262fb80a5a53ec436ab0e59b4f33be70082ea9dd78650e2a97
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Total.js include un database NoSQL integrato. `NOSQL('name')` apre il file di database `databases/name.nosql` e lo crea al primo utilizzo. Le operazioni restituiscono un builder: concatena `.where()` e termina con `.callback(function(err, response) {})`.

```js definitions/notes.js
NEWACTION('Notes/insert', {
	name: 'Insert a note',
	input: '*text:String',
	action: function($, model) {
		model.id = UID();
		NOSQL('notes').insert(model).callback(function() {
			$.success(model.id);
		});
	}
});

NEWACTION('Notes/query', {
	name: 'List notes',
	action: function($) {
		NOSQL('notes').find().callback(function(err, response) {
			$.callback(response);
		});
	}
});
```

```js controllers/notes.js
exports.install = function() {
	ROUTE('POST /notes/ --> *Notes/insert');
	ROUTE('GET /notes/ --> *Notes/query');
};
```
