@@ -57,15 +57,15 @@ router.post('/', async (req, res) => {
5757 let ec ;
5858 try {
5959 if ( req . body . name !== undefined ) {
60- const { name, phone, email, UserId, entities } = req . body ;
60+ const { name, phone, email, UserId, entities, attributes } = req . body ;
6161
6262 // Validating emails
6363 if ( email ) {
6464 const goodEmail = utils . validateEmails ( email ) ;
6565 if ( ! goodEmail ) return utils . response ( res , 422 ) ;
6666 }
6767
68- contact = await req . context . models . Contact . create ( { name, email, phone, UserId } ) ;
68+ contact = await req . context . models . Contact . create ( { name, email, phone, UserId, attributes } ) ;
6969 if ( entities ) {
7070 for ( const entity of entities ) {
7171 ec = {
@@ -99,7 +99,7 @@ router.put('/', async (req, res) => {
9999 let ec ;
100100 try {
101101 if ( validator . isUUID ( req . body . id ) ) {
102- const { id, name, phone, email, UserId, entities } = req . body ;
102+ const { id, name, phone, email, UserId, entities, attributes } = req . body ;
103103
104104 // Validating emails
105105 if ( email ) {
@@ -120,6 +120,7 @@ router.put('/', async (req, res) => {
120120 contact . email = ( email ) ? email : contact . email ;
121121 contact . UserId = ( UserId ) ? UserId : contact . UserId ;
122122 contact . updatedAt = new Date ( ) ;
123+ contact . attributes = ( attributes ) ? attributes : contact . attributes
123124
124125 await contact . save ( ) ;
125126
0 commit comments