以下是模型user中的user.js模式 -
var userSchema = new mongoose.Schema({
local: {
name: { type: String },
email : { type: String, require: true, unique: true },
password: { type: String, require:true },
},
facebook: {
id : { type: String },
token : { type: String },
email : { type: String },
name : { type: String }
}
});
var User = mongoose.model('User',userSchema);
module.exports = User;
Run Code Online (Sandbox Code Playgroud)
这就是我在我的控制器中使用它的方式 -
var user = require('./../models/user.js');
Run Code Online (Sandbox Code Playgroud)
这就是我在db中保存它的方法 -
user({'local.email' : …Run Code Online (Sandbox Code Playgroud) 我是Node.js的新手,希望使用流程运行程序.对于其他程序,我不得不同时启动一个服务器(mongodb,redis等),但我不知道我是否应该用这个运行一个.请让我知道我哪里出错了,以及如何纠正这个问题.提前致谢.
这是该计划:
var http = require('http'),
feed = 'http://isaacs.iriscouch.com/registry/_changes?feed=continuous';
function decide(cb) {
setTimeout(function () {
if (Date.now()%2) { return console.log('rejected'); }
cb();
}, 2000);
}
http.get(feed, function (res) {
decide(res.pipe.bind(res, process.stdout));
//using anonymous function instead of bind:
// decide(function () {
// res.pipe(process.stdout)
// });
});
Run Code Online (Sandbox Code Playgroud)
这是cmd输出:
<b>C:\05-Employing Streams\05-Employing Streams\23-Playing with pipes>node npm_stre
am_piper.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1583:20)
at TCP.onread (net.js:527:27)
</b>
Run Code Online (Sandbox Code Playgroud) 这是我的表数据 Student

这是我的疑问 -
SELECT id, SUM( maths + chemistry + physics ) AS total, maths, chemistry, physics
FROM `student`
Run Code Online (Sandbox Code Playgroud)
但它扔了一排 -
id total maths chemistry physics
118 760 55 67 55
Run Code Online (Sandbox Code Playgroud)
虽然我想申请所有ID的金额....让我知道我怎么能实现这一目标?
如果在客户端禁用了javascript,我想标记一条消息.我在这里搜索并找到<noscript>用于处理这些东西的标签.
我在w3schools编辑做了这个检查,但它没有工作让我知道这<noscript>是不是意味着这个或我在这部分缺少的其他东西?

我正在关注Node.js教程.
我不确定的两行是:
app.set('view engine', 'html');
app.engine('html', hbs.__express);
Run Code Online (Sandbox Code Playgroud)
我检查了文档,app.set它只告诉我:
将设置名称指定给值.
但我的问题是使用它的相关性.我用谷歌搜索它,以前app.engine使用app.set过的地方.
让我知道app.set之前使用的重要性app.engine.
编辑
我发现了以下行,但我仍然不清楚,因为我第一次使用模板引擎:
但是我们可以通过使用
view engine指令告诉Express将HTML文件视为动态,您可以在上面看到.
这是工作代码,但我想知道如何不使用另一个对象(评论$foo)如何使用该对象的printItem()方法.新的oop编程概念所以可能是一个弱的问题,但真的无法找到:(class Foo$bar
我使用范围解析操作人员使用printItem()的Foo class,现在我的查询时,我们可以使用这个功能,那么什么是使用创建的对象?何时在适当的编码环境中使用范围解析运算符.
<?php
class Foo
{
public function printItem($string)
{
echo "This is in class Foo ". $string ."<br />";
}
public function printPHP()
{
echo "PHP is great "."<br />";
}
}
class Bar extends Foo
{
public function printItem($string)
{
echo "This is in class Bar ". $string ."<br />";
}
}
//$foo = new Foo;
$bar = new Bar;
$bar->printPHP();
$bar->printItem("Bar class object");
//Foo::printItem("Mental Case");
Run Code Online (Sandbox Code Playgroud) 我只是一个git启动器,基本上我克隆了一个git存储库,现在我想提交我在文件中所做的更改.当我运行命令时,git commit它说not a git repository,
所以作为git的首发我只是想问我是否需要先运行此命令 - git init然后git commit呢?或者在这些提交文件后要遵循的更多步骤之间?
我需要在Bitbucket上提交文件.
Screenshot-

对不起,如果它的标题听起来很简单。我在问之前谷歌但无法理解https://www.google.co.in/?q=what+is+a+persistent+login+session。
我正在关注提到它的PassportJS文档 -
认证成功后,Passport 将建立一个持久的登录会话。
这究竟persistent login session意味着什么以及它在nodejs或上下文中的简单会话方面有何不同passportJS。
做外壳和命令提示符下指的是同样的事情,即适用于Windows和shell命令行* NIX操作系统?或者还有什么要知道的吗?
实际上,我在命令提示符下使用 MySQL,并且正在学习一些关于此的教程,他们使用的是“ shell ”,所以我想问问。我在谷歌上搜索过,有些人认为它们是一样的,有些人则不然,所以我想从编码人员那里得到更具体的答案。
以下是前端的代码,其中storeSelUserId包含用于发送消息的user_id-
仅供参考 - 节点版本1.1.0
// Socket Notification
var socket = io('http://localhost:6868');
socket.on('connection', function (data) {
socket.emit('send notification', { sent_to: storeSelUserId });
});
Run Code Online (Sandbox Code Playgroud)
以下是路由文件中的服务器代码 -
var clients = {};
io.on('connection', function (socket) {
socket.emit('connection', "Connection Created.");
socket.on('send notification', function (sent_to) {
console.log(sent_to);
});
});
Run Code Online (Sandbox Code Playgroud)
在控制台sent_to中显示数组user_id.
socket.io我现在是一个先发制人,我坚持使用解决方案,如何将消息发送给这些特定的用户ID.
我搜索并发现我需要用其套接字推送每个用户,所以我将其改为 -
var users = [];
io.on('connection', function (socket) {
users.push({socket_id: socket.id});
socket.emit('connection', "Connection Created.");
socket.on('send notification', function (sent_to) {
console.log(sent_to);
});
});
Run Code Online (Sandbox Code Playgroud)
但是我处于两难境地,我还需要做什么来存储user_id哪个socket_id然后用特定的id更新用户的div?
编辑 - …
node.js ×5
express ×3
mysql ×2
bitbucket ×1
git ×1
git-clone ×1
git-commit ×1
inheritance ×1
javascript ×1
logic ×1
mean-stack ×1
mongodb ×1
mongoose ×1
noscript ×1
oop ×1
passport.js ×1
persistence ×1
php ×1
session ×1
shell ×1
socket.io ×1
sockets ×1
sql ×1
sum ×1
windows ×1