我如何获得同名员工的所有ID

时间:2019-06-28 11:43:44

标签: sql grails gorm

我想编写一个GORM查询,该查询可以列出同名所有员工的ID

数据库格式为:

=ARRAYFORMULA(REGEXREPLACE(E2:E*D2:D&"", "^0", ))*1

结果应该像

       {
           props.login?<div><h1>Login:{props.login}</h1><Fetchapi apiID ={apiID}/></div>: <div className="mbox">
           <h3>{props.message}</h3>
       </div>    
     }```

child component(very bid showing necessary part)


```class Fetchapi extends Component {
  constructor(props) {
    super(props);

    this.state = { 
      datas:[],
      more_leads:true,
      show:false,   // for modal toggling
      currentPage:1,
      rowsPerPage:10,
      clickedData:{
        "First Name":"",
        "Last Name":"",
          "Email":"",
          "ID":"",
          "Country":"",
          "Mobile":""
        }
      };
      this.handleNext = this.handleNext.bind(this);
      this.handlePrevious = this.handlePrevious.bind(this);
      this.handleShow = this.handleShow.bind(this);
      this.handleShow = this.handleShow.bind(this);
      // Modal Funtions

    }

and many more codes 
-
-
-
componentDidUpdate() {


  fetch(req)
    .then(response=> response.json())
    .then(users => {

        if(this._isMounted)
        {
          this.setState({ datas: users.response,
          more_leads:users.is_more_leads_available
        })
      }


    });

  console.log("apiID from fetch",this.props.apiID)  ;// this code gives undefined in console.log

}


I even tried to render in the DOM
```<h1>{this.props.apiID}</h1>```

1 个答案:

答案 0 :(得分:0)

id列是一个集合,因此最好将其称为ids

用sql处理一行中的一行对于您的同事来说不是一件容易的事,如果您必须加载大量数据并且可能会遇到性能问题,我只会使用它。

因此,我建议您在Java代码中使用简单的findAllByEmployee查询和group by Employee

如果由于对象脱水而希望节省一些带宽和CPU,则可以使用criteria仅加载所需的属性:

def result = Empoloyee.createCriteria().list{
    projections {
        property 'id'
        property 'EMPOLYEE'
    }
    // Paging if needed
}

def empolyeeToIdsMap = result.groupBy {it.EMPLOYEE}

免责声明: 没有尝试过代码,可能包含错误。