mongodb查找不在特定日期的记录

时间:2018-08-25 08:00:49

标签: node.js mongodb mongoose

我找不到一种方法来获取未在特定日期创建的记录。日期为iso格式,但我只需要比较日期部分(不包括时间)。

like where rec_date != '2018-08-02' 

我已经很难获取特定日期的记录,但是我可以使用以下方法进行管理

    var param_date = '2018-08-23T09:47:00Z'

    var day = moment(param_date, "YYYY-MM-DD")
    var pday = moment(param_date, "YYYY-MM-DD").subtract(1, 'day')
    var nday = moment(param_date, "YYYY-MM-DD").add(1, 'day')



     Model.find({
      $and: [

        // match exact date
          {"rec_date": {$gt: day}},
          {"rec_date": {$lt: day2}}


      ]
  },

            function(err,docs) { 
                 res.json(docs)
            } );

但是我不知道该怎么做

$ ne似乎不起作用,因为它正在比较整个ISO日期,只需要比较日期部分即可。

1 个答案:

答案 0 :(得分:1)

找到确切日期时,您可以执行与当前操作相反的操作:

#include <SFML/Graphics.hpp>
#include <iostream>

int main(){
  sf::RenderWindow window(sf::VideoMode(800, 600), "This is the title");
  window.setFramerateLimit(60);

  sf::RectangleShape rect(sf::Vector2f(20, 20));
  rect.setFillColor(sf::Color::Green);
  rect.setPosition(sf::Vector2f(50, 50));

  // Timing
  sf::Clock clock;

  while (window.isOpen()){
    // Update the delta time to measure movement accurately
    sf::Time dt = clock.restart();

    // Convert to seconds to do the maths
    float dtAsSeconds = dt.asSeconds();

    // For debuging, print the time to the terminal
    // It illustrates the differences
    std::cout << "Time step: " << dtAsSeconds << '\n';

    // Calculate movement per dt
    // Since the dt is a very small number, 
    // you have to multiply it with a large number to see faster movement
    float movement = 250.0f * dtAsSeconds;

    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)){
      rect.move(0, -movement);
    }

    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
      rect.move(0, movement);
    }

    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
      rect.move(-movement, 0);
    }

    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
      rect.move(movement, 0);
    }


    sf::Event event;
    while (window.pollEvent(event)){
      if (event.type == sf::Event::Closed){
        window.close();
      }
    }

    window.clear();

    window.draw(rect);

    window.display();
  }

  return 0;
}
相关问题