# Store and read data with the embedded NoSQL database

> Insert and query documents with NOSQL() and expose them through actions, without installing any database.

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

Total.js ships with an embedded NoSQL database. `NOSQL('name')` opens the database file `databases/name.nosql`, creating it on first use. Operations return a builder: chain `.where()` and finish with `.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');
};
```
