1

I have this custom data in the channel

{
 channelHashId: '111122222',
 cid: '111111',
 data: {
   custom: {
     name: "testing"
   }
 }
 address: "my address",
}

i tried

const filter = { type: 'messaging', data: { custom: { name: 'testing' }  } };
const sort = [{ last_message_at: -1 }]; 

const channels = await chatClient.queryChannels(filter, sort, {
    watch: true, // this is the default
    state: true,
});

but i get an error 'invalid field operation',

but if i do

const filter = { type: 'messaging', address: 'my address'  } };
const sort = [{ last_message_at: -1 }]; 

const channels = await chatClient.queryChannels(filter, sort, {
    watch: true, // this is the default
    state: true,
});

it works fine

please help

luis
  • 202
  • 5
  • 13

1 Answers1

0

Use queryMembers (see docs) instead of queryChannels.

Under the hood, since the data field is of a reference type (an object), queryChannels would compare the reference instead of the content of your object.

Dorin Botan
  • 1,224
  • 8
  • 19
  • isn't queryMembers only look for members information in the channel? how would this search for data in the channel object? – luis Nov 23 '22 at 16:44