Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array with object with reference! #270

Open
2 tasks done
williamneves opened this issue Feb 23, 2024 · 0 comments
Open
2 tasks done

Array with object with reference! #270

williamneves opened this issue Feb 23, 2024 · 0 comments

Comments

@williamneves
Copy link

williamneves commented Feb 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Question

I have this follow schema:

{
  name: "program",
  title: "Programa",
  description: "Etapas do programa",
  type: "array",
  of: [{
    type: "object",
    fields: [{
      name: "step",
      title: "Etapa",
      type: "string",
    },
    {
      name: "etd",
      title: "Tempo Estimado de duração",
      type: "number",
      initialValue: 5,
    },
    {
      name: "colaborador",
      title: "Colaborador",
      type: "reference",
      to: [{
        type: "colaborador"
      }],
    },
    ],
  },
  ],
},

and my problem is, I cant fetch with the colaborador reference, the query I have so far is:

q("*")
    .filter("_type == 'devocional'")
    .grab$({
      title: q.string(),
      musicas: q('musicas')
      .filter()
      .deref()
      .grab$({
        title: q.string()
      }),
      program: q.array(q.object({
        step: q.string(),
        eta: q.string(),
        colaborador: q('colaborador', {isArray: false}).
        filter()
        .grab$({
          name: q.string()
          })
      }))
    }),

And this is not fetching, and this the query generated:

*[_type == 'devocional']{title, "musicas": musicas[]->{title}, program}

And this is a response:

title: "Visita a uma prisão"
musicas: [...] 4 items
0: {...} 1 properties
title: "A Alegria"
1: {...} 1 properties
title: "Quão bom e Quão maravilhoso"
2: {...} 1 properties
title: "Ninguém explicada Deus"
3: {...} 1 properties
title: "Entra na minha casa"
program: [...] 6 items
0: {...} 3 properties
etd: 5
step: "Orção inicial - Convidar um colcaborador"
_key: "c94a88d3d7c8"
1: {...} 3 properties
step: "momento musical com Todos"
_key: "bd231ce27d9c"
etd: 10
2: {...} 3 properties
_key: "c5e179d96e2a702826a76f1cc05dbcf4"
etd: 10
step: "Participação Especial/ Dueto"```

No colaborador at the response.

Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant