The table created by mongoose will automatically add a character's'
For example, the table created by the following code is test_table, but actually test_tables
var mongoose = require("mongoose");
mongoose.connect("mongodb://192.168.1.17:27017/testdb",function(e){
if(e)
console.log(e.message);
console.log("connect yes!");
});
var Schema = mongoose.Schema; // Create model
var userScheMa = new Schema({ carrier: String, lang: String, impCount: Number, clickCount: Number, }); // A new model is defined, but this model is not yet associated with the test_table collection var data = mongoose. model('test_table", userScheMa); // associated with the test_table collection exports.query = function(req, res){ var key1 = {carrier: "$carrier", lang: "$lang"} var query1 = {'$ or': [{'impCount': {'$gt': 3}},{'impCount': {'$lt': 16}}]} var sort1 = {os: -1} var limit1 = 3 var skip1 = 0 data.aggregate( [ {$match: query1}, {$group: {_id: key1, ImpCount: {$sum: "$impCount" }, ClickCount:{$sum: "$clickCount" }}},
{ $sort: sort1},
{ $limit: limit1 },
{ $skip : skip1}
],function(e,docs)
{
if(e)
console.log(e.message);
res.send(JSON.stringify(docs));
}
);
}