Hello All,
How can I create a report for each user detailing the interaction with documents stored in SharePoint Online libraries? Very beautiful article and useful for all SharePoint Online implementer,
Thanks to, Tony Redmond
Hello All,
How can I create a report for each user detailing the interaction with documents stored in SharePoint Online libraries? Very beautiful article and useful for all SharePoint Online implementer,
Thanks to, Tony Redmond
Hello All,
Very nice Article, for see how to convert a Word Document to PDF in SharePoint Document Library using Power Automate without using any licence version.
Thanks Chandani Prajapati.
1
|
npm init -y
|
package.json file.npm when we ask it to run our application. This file can have object instances of multiple modules that we write as well as third party modules that we install from the npm directory.
1
2
|
touch app.js
npm install express mongodb body-parser --save
|
app.js which will be the main entry point to the application, and we installed a few dependencies that are essential to start our application.body-parser: This package will allow us to handle request bodies with Express.
1
2
3
4
5
6
7
8
|
const Express = require("express");
const BodyParser = require("body-parser");
const MongoClient = require("mongodb").MongoClient;
const ObjectId = require("mongodb").ObjectID;
var app = Express();
app.use(BodyParser.json());
app.use(BodyParser.urlencoded({ extended: true }));
app.listen(5000, () => {});
|
1
|
node app.js
|
app.js and make the following changes to the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
const Express = require("express");
const BodyParser = require("body-parser");
const MongoClient = require("mongodb").MongoClient;
const ObjectId = require("mongodb").ObjectID;
const CONNECTION_URL = ;
const DATABASE_NAME = "accounting_department";
var app = Express();
app.use(BodyParser.json());
app.use(BodyParser.urlencoded({ extended: true }));
var database, collection;
app.listen(5000, () => {
MongoClient.connect(CONNECTION_URL, { useNewUrlParser: true }, (error, client) => {
if(error) {
throw error;
}
database = client.db(DATABASE_NAME);
collection = database.collection("personnel");
console.log("Connected to `" + DATABASE_NAME + "`!");
});
});
|
CONNECTION_URL property according to the connection string you received from MongoDB Atlas. We’ve also defined the database name which we wish to create (if not already present and collection).app.js:
1
2
3
4
5
6
7
8
|
app.post("/personnel", (request, response) => {
collection.insert(request.body, (error, result) => {
if(error) {
return response.status(500).send(error);
}
response.send(result.result);
});
});
|
/personnel endpoint, we take the body and insert it into our collection. Depending on the success or error response of the database, we return information back to the client.
1
2
3
4
|
curl -X POST \
-H 'content-type:application/json' \
-d '{"firstname":"John","lastname":"Doe"}' \
http://localhost:5000/personnel
|
accounting_department and under collection personnel. Feel free to add more records to your database.app.js:
1
2
3
4
5
6
7
8
|
app.get("/personnel", (request, response) => {
collection.find({}).toArray((error, result) => {
if(error) {
return response.status(500).send(error);
}
response.send(result);
});
});
|
{} in the find command, and the results get converted into an array.
1
|
curl -X GET http://localhost:5000/personnel
|
app.js:
1
2
3
4
5
6
7
8
|
app.get("/personnel/:id", (request, response) => {
collection.findOne({ "_id": new ObjectId(request.params.id) }, (error, result) => {
if(error) {
return response.status(500).send(error);
}
response.send(result);
});
});
|
id which will represent an object id in MongoDB. Using the findOne method, we can get a single record based on the criteria included in the object. The id isn’t a string which is why we have to use the ObjectId.
1
|
curl -X GET http://localhost:5000/personnel/4b103f89403f841059524fd1
|