用数组替换mongoDB查询中的表达式

时间:2018-02-17 04:34:36

标签: javascript node.js mongodb

我有一个mongoDB查询

    (ronin) pratyusha@pratyusha-Q304UAK:~/Projects/ronin$ python Retrieval-Eval.py
No handlers could be found for logger "gensim.models.doc2vec"
<IPython.core.display.HTML object>
Can you suggest a spa for us?
Are transport facilities available here?
Traceback (most recent call last):
  File "Retrieval-Eval.py", line 484, in <module>
    e = evaluate(dialogue, dtype="str", concept_weight=1.0, task_weight=0)
  File "Retrieval-Eval.py", line 248, in evaluate
    retrieval2 = get_skipsim_matches(selected=questions, dtype="str", conceptW=concept_weight, taskW=task_weight)  #HERE !!!!!!!!!!!!!
  File "Retrieval-Eval.py", line 446, in get_skipsim_matches
    conceptDictionary = get_skipsim_concept_dictionary(selected[1:], dtype)   
  File "Retrieval-Eval.py", line 464, in get_skipsim_concept_dictionary
    scores = get_list_skipsim_scores(selected, dialogue, dtype)   
  File "Retrieval-Eval.py", line 430, in get_list_skipsim_scores
    score = st.get_sim_score(q1, q2)    
  File "/home/pratyusha/Desktop/neon/examples/skipthought/inference.py", line 132, in get_sim_score
    a = self.get_sentence_vec(text1)
  File "/home/pratyusha/Desktop/neon/examples/skipthought/inference.py", line 50, in get_sentence_vec
    parser = NeonArgparser(__doc__)
  File "/home/pratyusha/.virtualenvs/ronin/local/lib/python2.7/site-packages/neon/util/argparser.py", line 80, in __init__
    super(NeonArgparser, self).__init__(*args, **kwargs)
TypeError: __init__() got multiple values for keyword argument 'add_config_file_help'

如何用数组替换表达式test.find({$or : [ {"timeIn":"2018-1-31 11:57"},{"timeIn":"2018-1-31 11:58"},{"timeIn":"2018-1-31 11:59"} ] }, {"email": 1, "_id": 0}).toArray(function (err,data){ if (err) throw err; console.log(data); }); 。喜欢这个

{"timeIn":"2018-1-31 11:57"},{"timeIn":"2018-1-31 11:58"},{"timeIn":"2018-1-31 11:59"}

2 个答案:

答案 0 :(得分:0)

尝试$in,需要匹配一组值

test.find({timeIn : {$in: ["2018-1-31 11:57","2018-1-31 11:58","2018-1-31 11:59"]}  }, {"email": 1, "_id": 0}).toArray(function (err,data){
  if (err) throw err;
  console.log(data);
});

答案 1 :(得分:0)

亚历克斯,你想要这样的东西:

var arrQuery = [];

var query1 = {'name':'AC3 Series Charger'};
var query2 =  {'price':200};
var query3 =  {'type':'tv'};
arrQuery.push(query1);
arrQuery.push(query2);
arrQuery.push(query3);

db.products.find({$or:arrQuery})

只需根据您的需要进行调整。