我在我的项目中使用angularjs v1.2.9.我使用dir-pagination在我的网络应用程序中显示项目列表.一些过滤器也用于动态地对列表进行排序.有没有办法让我在控制器中获取动态排序列表?我尝试了这里给出的解决方案.但他们似乎并没有使用dir-pagination.
<tr dir-paginate="person in contacts|filter:searchText|filter:groups|orderBy:['name','email'] | itemsPerPage : 10"
Run Code Online (Sandbox Code Playgroud) 任何人都可以帮我将这个mongoDB聚合转换为spring数据mongo吗?
我想在每个邀请文档中获取未提醒的与会者电子邮件列表.
得到它在mongo shell中工作,但需要在Spring数据mongo中完成.
我的shell查询
db.invitation.aggregate(
[
{ $match : {_id : {$in : [id1,id2,...]}}},
{ $unwind : "$attendees" },
{ $match : { "attendees.reminded" : false}},
{ $project : {_id : 1,"attendees.contact.email" : 1}},
{ $group : {
_id : "$_id",
emails : { $push : "$attendees.contact.email"}
}
}
]
Run Code Online (Sandbox Code Playgroud)
)
这就是我提出的,正如您所看到的,它在管道的项目和组操作中的工作效果并不如预期.生成的查询如下.
聚合对象创建
Aggregation aggregation = newAggregation(
match(Criteria.where("_id").in(ids)),
unwind("$attendees"),
match(Criteria.where("attendees.reminded").is(false)),
project("_id","attendees.contact.email"),
group().push("_id").as("_id").push("attendees.contact.email").as("emails")
);
Run Code Online (Sandbox Code Playgroud)
它创建以下查询
Aggregation对象生成的查询
{ "aggregate" : "__collection__" , "pipeline" : [
{ "$match" : { "_id" : …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Model上实现实例函数.它检查模型实例的字段值expiresAt是否超出特定时间戳.这是我的架构
let MySchema = new mongoose.Schema({
userId : { type : ObjectId , unique : true, required: true },
provider : { type : String, required : true},
expiresAt : { type : Number, required : true}
},{ strict: false });
Run Code Online (Sandbox Code Playgroud)
这是实例方法
MySchema.methods.isExpired = () => {
console.log(this.expiresAt) // undefined
return ( this.expiresAt < (Date.now()-5000) )
};
Run Code Online (Sandbox Code Playgroud)
但是价值this.expiredAt是未定义的.然后我尝试重写该函数如下
MySchema.methods.isExpired = () => {
try{
console.log(this._doc.expiresAt);
console.log((Date.now()-5000));
return (this._doc.expiresAt < (Date.now()-5000));
} catch (e){
console.error(e);
}
}; …Run Code Online (Sandbox Code Playgroud) 我正在尝试从我的 Nodejs 应用程序发送电子邮件。我为此使用了Nodemailer包。这是我用于发送电子邮件的代码;
let smtpTransport = nodemailer.createTransport({
host: "box***.bluehost.com",
port: 465,
secure: true,
auth: {
user: <noreply@mydomain.com>,
pass: <password>
}
});
let sendResetPasswordEmail = (user, token) => {
let mailOptions = {
to : user.workEmail,
subject : "Reset your password",
text : _generateResetPasswordEmail(user, token)
}
smtpTransport.sendMail(mailOptions, (error, response) => {
if(error){
console.error(error);
} else {
console.log("Message sent: " + response.message);
console.log(response);
}
});
}
Run Code Online (Sandbox Code Playgroud)
在smtpTransport.sendMail函数的回调中,错误为空,这是我得到的响应
{
accepted: [ 'toemail@somedomain.com' ],
rejected: [],
response: '250 OK id=short-hyphenated-alpha-numeric-id>', …Run Code Online (Sandbox Code Playgroud)