小编Ech*_*cho的帖子

节点js/Mongoose .find()

我在节点js服务器上使用mongoose中的.find()函数时遇到了麻烦我一直在尝试使用它但我无法从我的数据库中获取关键信息.

user.find({key: 1} , function(err, data){
  if(err){
    console.log(err);
  };
  console.log("should be the key VVV");
  console.log(data.key);
});
Run Code Online (Sandbox Code Playgroud)

我主要是在解决这个函数如何接受查询并让你从数据库中回复响应时遇到麻烦.如果有人可以打破它,请非常感谢mongoose docs没有多大帮助.

如果它有帮助,这也是我的用户架构

var userSchema = new mongoose.Schema({
  username: {type: String, unique: true},
  password: {type: String},
  key: {type: String},
  keySecret: {type: String}
}, {collection: 'user'});


var User = mongoose.model('user',userSchema);

module.exports = User;
Run Code Online (Sandbox Code Playgroud)

javascript mongoose node.js

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

视图 | vue-moment.js 的问题

我在 .vue 文件中实现 vue-moment 或 moment.js 时遇到了问题。所以我想在 vue 方法中有一个日期,然后我可以操纵它来查找过去时间和当前时间之间的时间跨度并实时更新它。所有的谷歌搜索都把我指向了 moment.js

我的 main.js 文件实现了

import VueMoment from 'vue-moment';

Vue.use(VueMoment);
Run Code Online (Sandbox Code Playgroud)

然后我尝试像这样访问模板中的方法

<p>{{ moment(1481889223).format('MMMM Do YYYY, h:mm:ss a') }}</p>
Run Code Online (Sandbox Code Playgroud)

是否有一些固有的东西我做错了。我只是似乎没有时间输出日期/时间

此外,如果这不是解决方案,是否还有另一种简单的方法来访问 .vue 文件中的日期时间?

javascript node.js momentjs vue.js vuejs2

3
推荐指数
1
解决办法
2269
查看次数

标签 统计

javascript ×2

node.js ×2

momentjs ×1

mongoose ×1

vue.js ×1

vuejs2 ×1