I'm trying to build a node cli to keep an organized planner. I have 'locate' command that goes to the options for commands either 'find' or 'list', but no data is being shown even though the mongoose functions are working correctly. 'todo locate list 12/31/1999' does not return any data back even though there are dates greater than that in my database. Coud someone help me debug this project. The GitHub repository is github.com/tripiod8/todo_cli
const mongoose = require('mongoose');
const Todo = require('../model/todoSchema');
// Find todo
const findTodoIn = (_tag) => {
Todo.find({ tag: "Birthday" })
.then(todo => {
console.info(todo);
console.info(`${todo.length} matches`);
mongoose.disconnect();
}).catch(err => console.error(err));
};
// List todo
const listTodoIn = (_date) => {
Todo.find( { date: { $gte: _date } } )
.then(todo => {
console.info(todo);
console.info(`${todo.length} matches`);
mongoose.disconnect();
}).catch(err => console.error(err));
};
module.exports = {
findTodoIn,
listTodoIn
};
const program = require('commander');
const {findTodoIn, listTodoIn} = require('../controllers/locate');
program
.command('find <tag>')
//.alias('f')
.description('Find a todo')
.action(_tag => findTodoIn(_tag))
program
.command('list <_date>')
// .alias('l')
.description('List a todo')
.action(_date => listTodoIn(_date));
program.parse(process.argv);
const program = require('commander');
program
.version(pkg.version)
.command('locate', 'Locate a todo')
program
.command('add')
.alias('a')
.description('Add a todo')
.action(() => {
prompt(questions).then((answers) => {
addTodoIn(answers)
})
});
program.parse(process.argv);