# Guarda y lee datos con la base NoSQL integrada

> Inserta y consulta documentos con NOSQL() y expónlos mediante acciones, sin instalar ninguna base de datos.

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

Total.js incluye una base de datos NoSQL integrada. `NOSQL('name')` abre el fichero `databases/name.nosql` y lo crea la primera vez que se usa. Las operaciones devuelven un builder: encadena `.where()` y 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');
};
```
