小编Ach*_*eka的帖子

带有 Express 框架的 ElasticSearch

我想建一个应用程序,这将主要是获取资源的API,现在我已经听说了很多关于NodejsElasticSearch我知道一点和的NodeJS快递框架。但我不知道如何将 ElasticSearch 与 Express 框架集成。

node.js express elasticsearch

6
推荐指数
1
解决办法
5029
查看次数

Graphql字段上的未知参数

我是GraphQL的新手,当我尝试发送args on(posts)子节点时,如下面的查询我得到一个错误消息"在用户类型的字段帖子上的未知参数id".我想带一些特定的帖子不是全部.

{ people(id:[1,2]) {
            id
            username
            posts(id:2) {
              title
              tags {
                name
              }
            }
          }
        }
Run Code Online (Sandbox Code Playgroud)

这是我的Schema.js文件..

var graphql = require('graphql');
var Db = require('./db');
var users  = new graphql.GraphQLObjectType({
  name : 'user',
  description : 'this is user info',
  fields : function(){
    return {
      id :{
        type : graphql.GraphQLInt,
        resolve(user){
          return user.id;
        }
      },
      username :{
        type : graphql.GraphQLString,
        resolve(user){
          return user.username;
        }
      },

      posts:{
        id:{
          type : graphql.GraphQLString,
          resolve(post){
            return post.id;
          }
        },
        type: new  graphql.GraphQLList(posts),
        resolve(user){
          return …
Run Code Online (Sandbox Code Playgroud)

javascript graphql

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

javascript变量的怪异行为

情况1 - 如果我在变量声明之前调用console.log(变量),我将得到未定义.例如;

  // code 
  console.log(a);
  var a ;

  // output
  undefined
Run Code Online (Sandbox Code Playgroud)

情况2 - 如果我没有变量声明的console.log(变量),我得到Uncaught ReferenceError:未定义变量.

// code
console.log(a);

// output
Uncaught ReferenceError: a is not defined
Run Code Online (Sandbox Code Playgroud)

但是我们可以在函数定义之前或之后调用函数,但它从不会产生任何问题.例如;

  console.log(example());

  function example(){
    return 'test done';
  }
  console.log(example());

 // output without any issue
Run Code Online (Sandbox Code Playgroud)

现在的问题是,是什么样的区别不确定的没有定义.

javascript

-4
推荐指数
1
解决办法
47
查看次数

标签 统计

javascript ×2

elasticsearch ×1

express ×1

graphql ×1

node.js ×1