1

我正在尝试构建一个节点 cli 以保持有组织的计划者。我有“定位”命令,该命令转到“查找”或“列表”命令的选项,但即使猫鼬功能正常工作,也没有显示任何数据。'todo locate list 12/31/1999' 不会返回任何数据,即使我的数据库中的日期大于那个日期。有人帮我调试这个项目。GitHub 存储库是 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);

4

0 回答 0