如何在Falcor中构建多参数搜索 [英] How to structure a multi-parameter search in Falcor

查看:64
本文介绍了如何在Falcor中构建多参数搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为Falcor查询构造搜索路径的最佳做法是什么?

What are the best practices in constructing search paths for Falcor queries?

在人员配备域中,有一个示例,其中人员配备协调员正在尝试为项目需求配备人员:

Here an example from a Staffing domain where a staffing coordinator is trying to staff people for project needs:

  • 需求具有startDateendDate-两者都是需求的简单字符串属性
  • 需要一个project,因此它引用了一个项目
  • 需要一个skill,因此它具有对技能的引用
  • A need has startDate and an endDate - both are simple string properties of the need
  • A need is for a project, hence it has a reference to a project
  • A need is for a skill, so it has a reference to a skill

以下是NeedMap中的需求:

Here's what a need looks like in a needMap:

needMap: {
    101: {
        startDate: '2016-07-04T04:00:00.000Z',
        endDate: '2016-10-22T03:59:59.999Z',
        project: $ref('projectMap[87]'),
        skill: $ref('skillMap[3]')
    },
    ...
}

如何指定符合以下条件的所有需求的搜索:

How do I specify a search for all needs that match the following criteria:

  • minStartDate:所需的最短开始日期
  • maxStartDate:所需的最大开始日期
  • projectId:仅需对此项目进行过滤
  • skillId:仅需具备此技能即可过滤
  • minStartDate: minimum start date for the need
  • maxStartDate: maximum start date for the need
  • projectId: filter to needs to only this project
  • skillId: filter to needs to only this skill

注意:我不是在寻找进行实际搜索的代码或想法,只是在寻找如何使用Falcor路径概念指定搜索.

Note: I am not looking for the code or ideas to do the actual search, only how to specify the search using Falcor path concepts.

推荐答案

问题#713 和github中的falcor储存库中的#775 可以解决此问题.出现两种可能的解决方案:

The issues #713 and #775 from the falcor repository in github address this. Two possible solutions appear :

  • 您可以使用查询字符串,对于您的情况,它将是这样的:model.get(["needs", "search", "minStartDate=2016&maxStartDate=2016&projectId=$ref(projectMap[87])])
  • 您可以使用另一个端点进行搜索,然后仅使用falcor来获取有关另一个端点返回的结果的更多信息

我猜另一种选择是使用call而不是get,因为这允许您传递多个参数.您会遇到这样的事情:

I guess another option would be to use a call rather than a get, as this allow you to pass multiple parameters. You would have something like this:

model.call(
    ["model", "search"],
    {
        minStartDate: "2016",
        maxStartDate: "2016",
        projectId: $ref('projectMap[87])
    },
    [],
    []);

这篇关于如何在Falcor中构建多参数搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆