Browse Source

search travels by from.name and to.name

master
arnaucode 8 years ago
parent
commit
983f9533a0
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      controllers/searchController.js
  2. +1
    -1
      models/travelModel.js

+ 2
- 2
controllers/searchController.js

@ -29,8 +29,8 @@ exports.searchByString = function (req, res) {
if (err) return res.send(500, err.message);
travelModel.find({
$or:[
{from: new RegExp(req.params.searchstring, "i")},
{to: new RegExp(req.params.searchstring, "i")},
{'from.name': new RegExp(req.params.searchstring, "i")},
{'to.name': new RegExp(req.params.searchstring, "i")},
{title: new RegExp(req.params.searchstring, "i")}
]
})//perquè retorni tots els objectes que continguin l'string sense necessitat de que sigui exactament la mateixa string

+ 1
- 1
models/travelModel.js

@ -19,7 +19,7 @@ var travelSchema = new Schema({
long: {type: Number},
name: { type: String, required: true }
},
date: { type: Date },
date: { type: Date, required: true },
periodic: { type: Boolean },
generateddate: { type: Date },
seats: { type: Number, required: true },

Loading…
Cancel
Save