.expand(keys)Since v0.3.0
Starter, Once - This can only be used once, at the start.
Accepts a single key or an array of keys.
Expands information from related collections. expand() is not needed if fields() is used, we automatically include what to expand. If used together with fields(), it overrides the automatic expansion.
Notes:
expand property (e.g. "expand": { "relField1": { ... }, ... }).Read more about expand in the official documentation.
const query = pbQuery<Post>()
.expand([
'author',
'comments_via_post',
])
.build(pb.filter);
console.log(query.fields); // Output: ''
console.log(query.expand); // Output: 'author,comments_via_post'
const records = await pb.collection('posts').getList(1, 20, query);
console.log(records);
// Output:
// [
// {
// expand: {
// author: { ... },
// comments_via_post: [
// { ... },
// ],
// },
// ...,
// },
// ]