What ref should I use if I want to reference the users-permission.User model?
Here’s the error I receive
Error Log
backend: TypeError: Cannot read property 'associations' of undefined
backend: at /home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-connector-mongoose/lib/relations.js:261:43
backend: at Array.forEach (<anonymous>)
backend: at /home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-connector-mongoose/lib/relations.js:242:20
backend: at Array.reduce (<anonymous>)
backend: at Function.update [as updateRelations] (/home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-connector-mongoose/lib/relations.js:97:68)
backend: at processTicksAndRejections (internal/process/task_queues.js:93:5)
backend: at runNextTicks (internal/process/task_queues.js:62:3)
backend: at processImmediate (internal/timers.js:434:9)
backend: at async Object.create (/home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-connector-mongoose/lib/queries.js:64:14)
backend: at async Object.create (/home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-database/lib/queries/helpers.js:15:18)
backend: at async Object.add (/home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-plugin-upload/services/Upload.js:302:17)
backend: at async Promise.all (index 0)
backend: at async Object.upload (/home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-plugin-upload/services/Upload.js:140:12)
backend: at async Object.afterFindOne (/home/jamesvibar/dev/bdobarterbuddy/packages/backend/extensions/users-permissions/models/User.js:35:28)
backend: at async executeLifecycle (/home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-database/lib/utils/lifecycles.js:7:5)
backend: at async Object.findOne (/home/jamesvibar/dev/bdobarterbuddy/node_modules/strapi-database/lib/queries/helpers.js:18:3)
Also, when you get this error: Cannot read property 'associations' of undefined on file uploads, that means the model that you indicated in ref is not correct.
Help! Trying to use the upload service as mentioned in this thread but my uploaded file (I am trying to add an avatar to users-permissions as well) never gets associated with the referenced user record. In debugging the service upload method, I can’t find anywhere where the ‘body’ data gets used to update the entity.
What doesn’t work exactly? If you are trying to add a file to an existing user entity, then these instructions work: Upload file to existing entity.
For a users-permissions user the fields are:
“ref”: “plugin::users-permissions.user”
“refId”: <the id of the user record you want to attach the file to, as a string>
“field”: <the name of your field in the user collection, for example ‘avatar’>
Make sure that you have allowed the upload action in the Authenticated Role under the Upload plugin section.
If you are trying to upload a file during a user registration (something that I needed), then it won’t work as it does with other content-types using the “Upload file during entry creation” instructions. Instead you have to re-implement the register function and upload the file after the user record is added (copy a lot of code from the plugin-users-permissions plugin auth controller) into your strapi-server.js file. If you do that, be warned as the dev team has updated the register code recently and it broke my version of it until I updated it to match their code.
I am facing an issue, I am uploading an image to “plugin::users-permissions.user”, the field is “profile_picture” using the multipart request, my problem is, if the image already exists in the field, then this method does not update the field with the new value, can anyone help me with this.