Skip to content

Commit 0d755bf

Browse files
use more modern js variable syntax
Co-authored-by: Gabriele Cimato <[email protected]>
1 parent f022f51 commit 0d755bf

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

snippets/functions/boilerplate/generalFunction.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ exports = async function (arg) {
44
// https://www.mongodb.com/docs/atlas/app-services/functions/
55

66
// Find the name of the MongoDB service you want to use (see "Linked Data Sources" tab)
7-
var serviceName = "mongodb-atlas";
7+
const serviceName = "mongodb-atlas";
88

99
// Update these to reflect your db/collection
10-
var dbName = "db_name";
11-
var collName = "coll_name";
10+
const dbName = "db_name";
11+
const collName = "coll_name";
1212

1313
// Get a collection from the context
14-
var collection = context.services
14+
const collection = context.services
1515
.get(serviceName)
1616
.db(dbName)
1717
.collection(collName);
1818

19-
var findResult;
19+
let findResult;
2020
try {
2121
// Get a value from the context (see "Values" tab)
2222
// Update this to reflect your value's name.
23-
var valueName = "value_name";
24-
var value = context.values.get(valueName);
23+
const valueName = "value_name";
24+
const value = context.values.get(valueName);
2525

2626
// Execute a FindOne in MongoDB
2727
findResult = await collection.findOne({
@@ -36,7 +36,7 @@ exports = async function (arg) {
3636
}
3737

3838
// To call other named functions:
39-
// var result = context.functions.execute("function_name", arg1, arg2);
39+
// const result = context.functions.execute("function_name", arg1, arg2);
4040

4141
return { result: findResult };
4242
};

0 commit comments

Comments
 (0)