代码拉取完成,页面将自动刷新
// Latte forum model base on MongoDB
// for CREATE operation ,when input unvailied throw exception
function Factory(){
this.post = function(ownner=null,title='',content='',topic='',nickname='',tags=[],replies=[],date=new Date(),edited_date=null,viewed=0,reply_n=0,star=0,hidden=false){
if(!ownner){
throw 'latte: need set ownner'
}else{
title = title.slice(0,60);
content = content.slice(0,5500);
return {
ownner,title,content,topic,nickname,tags,replies,date,edited_date,viewed,reply_n,star,hidden
}
}
};
this.reply = function(ownner=null,content='',post_id=null,nickname='',discuz=[],date=new Date(),hidden=false){
if(!ownner || !post_id || !content){
throw 'latte: need set ownner'
}else{
content = content.slice(0,750);
return {
ownner,content,post_id,nickname,discuz,date,hidden
}
}
};
this.user = function(account='',pwd='',nickname='',email='',avatar='',posts=[],replies=[],star_list=[],group=100,date=new Date(),near_login=null,hidden=false){
if(account&&pwd){
if(account.length>50 || pwd.length>50){
throw 'Latte : account or password too long'
}else if( account.length<5 || pwd.length<5 ){
throw 'Latte : account or passsword too short'
}else{
email = email.slice(0,60);
avatar = avatar.slice(0,500);
nickname = nickname.slice(0,60);
if(!nickname){ nickname = 'someone'};
return {
account,pwd,nickname,email,avatar,posts,replies,star_list,group,date,near_login,hidden
}
}
}else{
throw 'Latte: need set account and pwd'
}
};
};
module.exports = new Factory()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。