let userData = await User.findOne(user.id);

let deviceId = [];

// if the fbDeviceId is not present in the user table
if (!userData.fbDeviceId) {

deviceId.push(req.body.deviceId);

} else {

//then assign all the fetched fbDeviceId to deviceId array
deviceId = userData.fbDeviceId;

//check if the deviceid exist or not
let index = userData.fbDeviceId.indexOf(req.body.deviceId);

//if not exist then push the new value to the array
if (index === -1) {
deviceId.push(req.body.deviceId);
}
}

// console.log('new deviceId', deviceId)
await User.update({ id: userData.id }).set({ fbDeviceId: deviceId });