@feardread/fear 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -101,32 +101,25 @@ exports.read = tryCatch(async (Model, req, res) => {
101
101
  */
102
102
  exports.create = tryCatch(async (Model, req, res) => {
103
103
  const documentData = { ...req.body };
104
-
105
104
  // Handle image uploads if present
106
105
  if (documentData.images) {
107
- // Parse comma-separated string to array if needed
108
- const imageArray = typeof documentData.images === 'string'
109
- ? documentData.images.split(',').map(item => item.trim())
110
- : documentData.images;
111
106
 
112
- let imageLinks = await cloud.uploadImages(imageArray);
107
+ documentData.images.split(',').map(item => item.trim());
113
108
 
114
- if (imageLinks) {
115
- documentData.images = imageLinks;
116
- console.log('Added Images:', imageLinks);
117
- }
109
+ const imageLinks = await cloud.uploadImages(documentData.images);
110
+
111
+ if ( imageLinks ) documentData.images = imageLinks;
118
112
  }
119
113
 
120
114
  console.log('Creating document:', documentData);
121
115
 
122
116
  const document = new Model(documentData);
123
- const result = await document.save();
124
-
125
- return res.status(201).json({
126
- result,
127
- success: true,
128
- message: `Document created successfully in ${Model.modelName} collection`
129
- });
117
+ await document.save()
118
+ .then((result) => {
119
+ return res.status(201).json({ result, success: true,
120
+ message: `Document created successfully in ${Model.modelName} collection`});
121
+ })
122
+ .catch((error) => {console.log('Error Saving document :: ', error);});
130
123
  });
131
124
 
132
125
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feardread/fear",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {