Skip to content

Instantly share code, notes, and snippets.

@yashwanth2804
Created January 23, 2019 03:15
Show Gist options
  • Save yashwanth2804/252b384fd25d8d0eebd6d388f024170a to your computer and use it in GitHub Desktop.
Save yashwanth2804/252b384fd25d8d0eebd6d388f024170a to your computer and use it in GitHub Desktop.
mongodb import and querys
./mongoimport --db dbname --collection coll --type csv --headerline --file path/restaurantsa9126b3.csv
Aggregate
await Restaurants
.aggregate([
{
$lookup: {
from: "restaurantsAdd", // collection name in db
localField: "Restaurant ID",
foreignField: "Restaurant ID",
as: "restaurantsAdd"
}
},
{ $match: { "Restaurant Name": { $regex: Res_Name, $options: 'i' } } },
{ $match: { "Cuisines": { $regex: Cuisines, $options: 'i' } } },
{ $sort: { [sort]: sortOrder } }
])
.skip(skip)
.limit(10)
.exec();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment