我正在尝试在服务器端发送电子邮件和密码,并检查是否存在具有这些值的文档(确实存在),但是当我results从查询中控制台记录时,它为空。
这是users集合中的文档:
{
"_id" : ObjectId("580bcf9874ae28934705c0fc"),
"email" : "johndoe@gmail.com",
"password" : "pass"
}
Run Code Online (Sandbox Code Playgroud)
这是我发送服务器端的内容:
{"email":"johndoe@gmail.com","password":"pass"}
Run Code Online (Sandbox Code Playgroud)
这是我的代码(更新):
mongo.connect('mongodb://localhost:27017', function (err, db) {
if (err) {
console.log("error: " + err); // logs nothing
} else {
var users = db.collection("users");
var tasks = db.collection("tasks");
app.post("/login", function(req, res) {
var emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var userInDb;
var userEmail = req.body.email;
var userPassword = req.body.password;
console.log(req.body.email); // logs "johndoe@gmail.com"
console.log(req.body.password); // logs "pass"
if (!userEmail || !userPassword) {
return res.sendStatus(403);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 EC2 实例中运行 Rails 6,但遇到以下错误:
Your version of SQLite (3.7.17) is too old. Active Record supports SQLite >= 3.8.
如果重要:
- 我的 gem 文件中有以下内容:gem 'sqlite3', '~> 1.4
- 我正在使用以下命令:rvmsudo rails server -p 80 -b 0.0.0.0
- 当我在rails s本地运行时,我没有遇到这个问题。
这与此处的问题相同,但所选答案特定于使用 AWS Cloud9。
编辑:
下面是运行后的结果sudo yum install build-essential libsqlite3-dev sqlite3 software-properties-common:
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
No package build-essential available.
No package libsqlite3-dev available.
No package sqlite3 available.
No package software-properties-common available.
Error: …Run Code Online (Sandbox Code Playgroud) 我正在制作一个非常简单的推荐系统,但我看到的问题是我需要通过一次提交操作对数据库进行两次不同的调用,但我不知道该怎么做。
该系统的总体思路如下:
这将存储在两个表中:
subscribers 表与 | id | email | referrer |referrals表与| id | subscriber_id | referrals |,其中推荐是订阅者推荐其他订阅者的次数再次,我想知道如何使用单个提交操作进行两次调用——一次用于新订阅者,另一次用于推荐信息。或者,如果这不是最好的方法,那么如何使用最佳实践来做到这一点。
我正在将 Heroku 与 Rails 6 和 Postgres 一起使用。我试图用来heroku open启动应用程序,但构建失败,这显示在日志中:
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use `ActiveSupport::LoggerSilence` instead (called from <top (required)> at /tmp/build_9537ba0878cb8933c15686548eb3ccb5/config/application.rb:7)
Missing encryption key to decrypt file with. Ask your team for your master key and write it to /tmp/build_9537ba0878cb8933c15686548eb3ccb5/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].
!
! Precompiling assets failed.
!
! …Run Code Online (Sandbox Code Playgroud)