{"size": 636, "ext": "js", "max_stars_repo_path": "app/repo/db.js", "max_stars_repo_name": "anonymint/image-search", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/repo/db.js", "max_issues_repo_name": "anonymint/image-search", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/repo/db.js", "max_forks_repo_name": "anonymint/image-search", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.7142857143, "max_line_length": 70, "alphanum_fraction": 0.6446540881}
'use stricts';

const low = require('lowdb');
//inmemory 
const db = low();
//file DB create storage and low
//const storage = require('lowdb/file-sync');
//const db = low('db.json', { storage });
const recentSearchNode = db('recentSearch');

function Repo() {

	this.save = function(term) {
		console.log('Save term:'+term);
		recentSearchNode.push({ term: term, when: new Date().toISOString()})
	}

	this.recentSearch = function(amount) {
		var amount = amount || 20;
		console.log(recentSearchNode);
		return recentSearchNode.chain()
							   .reverse('when')
							   .take(amount)
							   .value();
	}
}

module.exports = Repo;