Closed Kellokes closed 4 years ago
Have you tried the new "Relations" api? https://docs.vulcanjs.org/relations.html
You should be able to drop query
and instead add relation: 'hasOne'
or relation: 'hasMany'
to resolveAs
Hi Erik,
I dropped the query and added the relation to resolvAs, but it didn't work, this error appears for me:
TypeError: Cannot read the 'name' property of undefined
I tried with fieldName: 'name' and 'field' ... This parameter is the field name of my relation collection that I want to show in the front-end, correct?
fieldsId:
label: 'Fields',
type: Array,
optional: false,
input: 'checkboxgroup',
resolveAs: {
fieldName: 'name',
type: '[Field]',
relation: 'hasMany'
},
canRead: ['members'],
canCreate: ['admins'],
canUpdate: ['admins'],
},
'fieldsId.$': {
type: String,
optional: false,
canRead: ['members'],
},
I resolved the problem, I forgot to define a fragments for each collection and configure them in my Datatable Component.
** The Card Component don't have a fragment option.
Hi Guys,
I'm trying to get the name field of Service Schema and Field schema trough the Form Schema using Resolve As, but when I pass the fields of ServiceId and FieldsId in the field parameters on the ComponentCard dind't appear the result with name fields of Service Schema and Field Schema.
I believe that ResolveAs it is not ready correctly with the component card.
What are the correct settings that I need to make when I need to obtain a specific field of a relationship between two collections?
Check my schema.js and FormsList.jsx
schema.js of Forms `const schema = { // default properties
};
export default schema;`
FormsList.jsx `import React from 'react'; import { Helmet } from 'react-helmet'; import { Components, withMulti, withCurrentUser, registerComponent } from 'meteor/vulcan:core'; import Users from 'meteor/vulcan:users';
import Forms from '../../modules/forms/collection.js';
const FormsList = ({ results = [], currentUser, loading, loadMore, count, totalCount }) => ( <div style={{ maxWidth: '500px', margin: '20px auto' }}>
const options = { collection: Forms, limit: 5, };
registerComponent({ name: 'FormsList', component: FormsList, hocs: [withCurrentUser, [withMulti, options]] });
`