小编And*_*rdi的帖子

使用Mongodb进行模糊搜索?

我已经设法在我的mongodb应用程序中设置搜索功能.请参阅下面的代码.这非常有效,但它只返回确切的结果.如何更改代码以使其接受更"模糊"的搜索结果?谢谢!

router.get("/", function(req, res){
    if (req.query.search) {
       Jobs.find({"name": req.query.search}, function(err, foundjobs){
       if(err){
           console.log(err);
       } else {
          res.render("jobs/index",{jobs:foundjobs});
       }
    }); 
    }

  Jobs.find({}, function(err, allJobs){
       if(err){
           console.log(err);
       } else {
          res.render("jobs/index",{jobs:allJobs});
       }
    });
});
Run Code Online (Sandbox Code Playgroud)

search mongoose mongodb

13
推荐指数
2
解决办法
1万
查看次数

在NodeJS中重置密码

我已经设置了使用NodeJS/Passport更新用户密码.我按照这个伟大的指南:http://sahatyalkabov.com/how-to-implement-password-reset-in-nodejs/.

其中99%是有效的.我不得不修改它以包含一些条带功能.我担心我在某个地方遇到了严重的错误,我找不到它.用户目前能够一直完成向他们发送电子邮件,输入新密码并登录的过程.另一封电子邮件说明他们的密码已成功更新.一切都很完美 然而.由于某些原因.新密码未被保存.用户只能使用旧密码登录.我已经尝试了一切我能想到的解决这个问题的方法.

我有其他几个程序员看这个,但没有一个能够弄清楚它在世界上是如何起作用的.

目前的想法是会话可能没有正确结束,但我们试图破坏会话,但它仍然无法正常工作.

任何帮助非常感谢.

完整设置:

用户模型:

var UserSchema = new mongoose.Schema({
    username:   { type: String, required: true, unique: true },
    password:  String,
    datapoint:  String,
    email:  { type: String, required: true, unique: true },
    resetPasswordToken: String,
    resetPasswordExpires: Date
});


UserSchema.pre('save', function(next) {
  var user = this;
  var SALT_FACTOR = 5;

  if (!user.isModified('password')) return next();

  bcrypt.genSalt(SALT_FACTOR, function(err, salt) {
    if (err) return next(err);

    bcrypt.hash(user.password, salt, null, function(err, hash) {
      if (err) return next(err);
      user.password = hash; …
Run Code Online (Sandbox Code Playgroud)

passwords mongodb node.js express passport.js

13
推荐指数
2
解决办法
2万
查看次数

上传时图像方向错误 - Amazon S3

我让用户使用Multer-S3 将多个图像直接上传到Amazon-S3,然后通过循环在前端显示这些图像.一切都很完美.

但是,当通过手机上传图像(在iPhone或Android上拍摄的图像)时,方向在移动设备上是正确的,但在桌面上没有正确的方向.主要问题.

这是由于我相信EXIF数据的图像.

看起来像ImageMagick或Kraken JS https://kraken.io/docs/storage-s3可能是一种解决方法,但对于我的生活,我无法弄清楚如何实现我上传和显示图像的方式如下所示.

我如何更改下面的代码以自动定位图像?注意:它必须适用于多个图像.

谢谢你的帮助!

Heres是我让用户一次将多个图像直接上传到Amazon-S3的方式:

aws.config.update({
    secretAccessKey: 'AccessKey',
    accessKeyId: 'KeyID',
    region: 'us-east-2'
});

var s3 = new aws.S3();

    var storage =  multerS3({
        limits : { files: 25 },
        s3: s3,
        bucket: 'files',
        key: function (req, file, cb) {
            var fileExtension = file.originalname.split(".")[1];
            var path = "uploads/" + req.user._id + Date.now() + "." + fileExtension;
            cb(null, path); 
        },
    })


var upload = multer({storage: storage}).any("images", 25);

router.post("/", middleware.isLoggedIn, function(req, res, …
Run Code Online (Sandbox Code Playgroud)

file-upload imagemagick image-processing amazon-s3 node.js

10
推荐指数
1
解决办法
4105
查看次数

Heroku 自定义域:sni_endpoint?

当向我的 Heroku 应用程序添加自定义域时,我遇到了以下错误。结果 Heroku 添加了一个新要求:Beginning November 1, 2021, this new parameter will be required: sni_endpoint

\n
heroku domains:add www.mywebsite.com \nAdding www.mywebsite.com to \xe2\xac\xa2 mywebiste... done\n\n     \xe2\x80\xba   Error: Require params: sni_endpoint.\n     \xe2\x80\xba   Error ID: invalid_params\n
Run Code Online (Sandbox Code Playgroud)\n

有人可以告诉我要使用的新语法吗heroku domains:add www.mywebsite.com

\n

heroku

10
推荐指数
1
解决办法
1359
查看次数

Heroku自定义域不起作用

将Heroku应用程序与自定义域连接的正确方法是什么?

这就是我过去的做法:

  1. 将Godaddy的DNS指向heroku提供的目标(例如:https: //peaceful-escarpment-22825.herokuapp.com)

  2. 在域上启用域转发

  3. 在设置中将域添加到Heroku

出于某种原因,我现在提供的Heroku目标是这样的:mycustomdomain.com.herokudns.com.当我将这个DNS添加到GoDaddy时,我得到了一个没什么的.页.

我哪里错了?谢谢!

dns heroku mongodb node.js

7
推荐指数
2
解决办法
6559
查看次数

使用点填充两个文本元素之间的空间

我想弄清楚如何自动填充两个对象之间的空间.我有菜单项和价格.

目标是这样的:

汉堡.......................... 9.99美元
牛排和土豆......... 14.99美元
Mac和奶酪...... ... $ 6.99

菜单项和价格之间的间距应该相同.用户可以输入菜单项和价格,我需要填写任何空格.

这是我尝试过但它不太有效:

.inLine {
  display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)
 <h1 class='inLine menuItem'> Burger </h1> 
<span class='inLine dots'> .....................</span>
<h3 class='inLine price'>  $9.99 </h3> 
<br>
<h1 class='inLine menuItem'> Steak </h1> 
<span class='inLine dots'> .....................</span>
<h3 class='inLine price'>  $14.99 </h3>

<h1 class='inLine menuItem'> Mediterranean Chopped Salad </h1> 
<span class='inLine dots'> .....................</span>
<h3 class='inLine price'>  $14.99 </h3>
Run Code Online (Sandbox Code Playgroud)

问题是无论项目名称有多长,点都需要占用正确的空间.我已经尝试设置点,width: 100%但似乎没有这样做.有任何想法吗?

html javascript css jquery space

5
推荐指数
1
解决办法
1710
查看次数

设置动画速度 - ChartJS?

我试图在chartJS中设置饼图的动画速度.

我尝试过以下方法:

  1. numSteps:数字,

  2. animationSteps:数字

    3.Chart.defaults.global.animationSteps = Number;

这些都没有改变速度.有什么建议?

 var myNewChart;
    var data = [
        {
        value: 30,
        label: "hello",
        color: "#F7464A"
      }, {
        value: 50,
        color: "#E2EAE9"
      }, {
        value: 100,
        color: "#D4CCC5"
      }, {
        value: 40,
        color: "#949FB1"
      }, {
        value: 100,
        color: "#4D5360"
      },

    ];


    var options = {
      animation: true,
      animationEasing: 'easeInOutQuart',
      animationSteps: 80,
      multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>"

    };


    var ctx = document.getElementById("myChart")
                                        .getContext("2d");

    myNewChart = new Chart(ctx).Doughnut(data, options);
Run Code Online (Sandbox Code Playgroud)

javascript jquery animation chart.js

5
推荐指数
2
解决办法
7676
查看次数

LocalStorage 不适用于移动设备?

我正在使用 localStorage 来备份长表单上的表单数据。因此,如果用户刷新,他们将不会丢失所有内容。这在计算机上的 Chrome 和 Firebox 上完美运行。

但是在移动设备上(至少在 iOS 上)它根本不起作用。有什么建议吗?

下面以我的一小部分代码为例:

存储数据:

 window.onbeforeunload = function() {
       window.localStorage.setItem("Job1", $("#topScore1B").text());
    }
Run Code Online (Sandbox Code Playgroud)

检索数据:

window.onload = function() {
    //   If values are not blank, restore them to the fields
        var name = window.localStorage.getItem('Job1');
        if (name !== null) $('#job1').text(name);


}
Run Code Online (Sandbox Code Playgroud)

html javascript jquery onload local-storage

5
推荐指数
1
解决办法
9301
查看次数

Apple Pay - “付款未完成” - 使用 Stripe

我正在使用条纹“付款请求按钮”为我的网站实施 Apple Pay。在事情的条纹方面一切都很好。当我在 Stripe 日志中验证时,令牌通过正确性传递。 https://stripe.com/docs/stripe-js/elements/payment-request-button

但是,每次尝试完成测试付款时,我都会收到来自 Apple Pay 的错误消息:“付款未完成”。

这让我卡住了,我不知道如何调试或修复。有任何想法吗?

我得到一个未定义的令牌

这是错误:

在此处输入图片说明

我的设置:

前端:

<script src="https://js.stripe.com/v3/"></script>
<div id="payment-request-button">
  <!-- A Stripe Element will be inserted here. -->
</div>



<script>
var stripe = Stripe('pk_test_xxxxx');

var paymentRequest = stripe.paymentRequest({
  country: 'US',
  currency: 'usd',
  total: {
    label: 'JobQuiz',
    amount: 999,
  },
  requestPayerName: true,
  requestPayerEmail: false,
});


var elements = stripe.elements();
var prButton = elements.create('paymentRequestButton', {
  paymentRequest: paymentRequest,
});

// Check the availability of the Payment Request API first.
paymentRequest.canMakePayment().then(function(result) {
  if (result) …
Run Code Online (Sandbox Code Playgroud)

payment node.js ios express stripe-payments

5
推荐指数
1
解决办法
2850
查看次数

使用CSS在圆圈周围旋转对象?

我试图围绕一个圆圈旋转三个物体.到目前为止,我已经能够让一个物体围绕圆圈旋转.如果不弄乱代码,我无法获得多个.任何人都可以建议最好的方法来实现这一目标吗?这是代码和小提琴的一部分.谢谢!

这是Demo

.outCircle {
  width: 200px;
  height: 200px;
  background-color: lightblue;
  left: 270px;
  position: absolute;
  top: 50px;
  -moz-border-radius: 100px;
  -webkit-border-radius: 100px;
  border-radius: 100px;
}
.rotate {
  width: 100%;
  height: 100%;
  -webkit-animation: circle 10s infinite linear;
}
.counterrotate {
  width: 50px;
  height: 50px;
  -webkit-animation: ccircle 10s infinite linear;
}
.inner {
  width: 100px;
  height: 100px;
  background: red;
  -moz-border-radius: 50px;
  -webkit-border-radius: 50px;
  border-radius: 100px;
  position: absolute;
  left: 0px;
  top: 0px;
  background-color: red;
  display: block;
}
@-webkit-keyframes circle {
  from {
    -webkit-transform: rotateZ(0deg) …
Run Code Online (Sandbox Code Playgroud)

html css css-animations

4
推荐指数
3
解决办法
9312
查看次数