webfast 0.1.70 → 0.1.71
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
const { MongoClient } = require('mongodb');
|
2
2
|
|
3
|
-
module.exports = async function(db, collection, condition, dataToCreate) {
|
3
|
+
module.exports = async function(db, collection, condition, dataToCreate,options = {}) {
|
4
4
|
// Ensure the MongoDB connection string is provided
|
5
5
|
if (!process.env.mongo) {
|
6
6
|
console.error('MongoDB connection string not provided. Set process.env.mongo.');
|
@@ -30,7 +30,7 @@ module.exports = async function(db, collection, condition, dataToCreate) {
|
|
30
30
|
const collection = database.collection(collectionName);
|
31
31
|
|
32
32
|
// Check if a document exists based on the condition
|
33
|
-
const existingDocument = await collection.findOne(condition);
|
33
|
+
const existingDocument = await collection.findOne(condition,options);
|
34
34
|
|
35
35
|
if (existingDocument) {
|
36
36
|
// If a document exists, return it
|
@@ -43,7 +43,7 @@ module.exports = async function(db, collection, condition, dataToCreate) {
|
|
43
43
|
|
44
44
|
if (result.acknowledged === true) {
|
45
45
|
console.log('New document created:', result.insertedId);
|
46
|
-
const existingDocument = await collection.findOne(condition);
|
46
|
+
const existingDocument = await collection.findOne(condition,options);
|
47
47
|
return dataToCreate;
|
48
48
|
} else {
|
49
49
|
console.error('Failed to create a new document.');
|
@@ -1,6 +1,6 @@
|
|
1
1
|
const { MongoClient } = require('mongodb');
|
2
2
|
|
3
|
-
module.exports = async function (db, collection, condition, dataToUpdate) {
|
3
|
+
module.exports = async function (db, collection, condition, dataToUpdate,options = { upsert: true }) {
|
4
4
|
// Ensure the MongoDB connection string is provided
|
5
5
|
if (!process.env.mongo) {
|
6
6
|
console.error('MongoDB connection string not provided. Set process.env.mongo.');
|
@@ -30,7 +30,7 @@ module.exports = async function (db, collection, condition, dataToUpdate) {
|
|
30
30
|
const collection = database.collection(collectionName);
|
31
31
|
|
32
32
|
// Perform the update or create operation
|
33
|
-
const result = await collection.updateOne(condition, { $set: dataToUpdate },
|
33
|
+
const result = await collection.updateOne(condition, { $set: dataToUpdate }, options);
|
34
34
|
|
35
35
|
// If a document was upserted, retrieve the upserted document
|
36
36
|
const upsertedDocument = result.upsertedId
|
package/modules/express/init.js
CHANGED
@@ -176,7 +176,7 @@ module.exports = async function (program) {
|
|
176
176
|
// Now read the dir
|
177
177
|
// Create app.get
|
178
178
|
try {
|
179
|
-
const theRoute =
|
179
|
+
const theRoute = `git pu${dirItem}/*`;
|
180
180
|
app.get(theRoute, async (req, res) => {
|
181
181
|
const params = req.params;
|
182
182
|
|
@@ -1,11 +1,13 @@
|
|
1
|
-
module.exports = async function(program, url, body) {
|
1
|
+
module.exports = async function(program, url, body,headers) {
|
2
2
|
console.log(`Fetch Post`);
|
3
3
|
// Register websocket url
|
4
4
|
try {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
if (headers == undefined) {
|
6
|
+
headers = {
|
7
|
+
accept: 'application/json',
|
8
|
+
'content-type': 'application/json'
|
9
|
+
};
|
10
|
+
}
|
9
11
|
|
10
12
|
let theOptions = {
|
11
13
|
method: 'POST',
|