Create REST API for ✨3d-inventory✨ application connected to Mongo Atlas — solution that allows you to build a spatial and database representation of yours datacenters.
MongoDB
is aNoSQL
database that stores data in a flexible,JSON
-like format.Express.js
is a web application framework for Node.js that simplifies the process of building web servers and APIs.AngularJS
is a 1JavaScript` framework for building dynamic web applications on the client-side.Node.js
is aJavaScript
runtime that allows you to run 1JavaScript1 code on the server-side.
Swagger API definition.
We can use MongoDB
or programming Mongo Atlas
API
.
https://www.mongodb.com/developer/languages/typescript/
new Promise(function (resolve, reject) {
collection
.find(query)
.cursor()
.on('data', function (doc) {
// ...
})
.on('error', reject)
.on('end', resolve)
}).then(function () {
// ...
})
It is generic code that can be tucked away in a utility function so it doesn't clutter application code and obstruct actual application logic.
In your example simplest utility function would be like
function streamToPromise(stream) {
return new Promise(function (resolve, reject) {
stream.on('end', resolve)
stream.on('error', reject)
})
}
And then the application code is simply
Promise.map(files, function (file) {
var stream = API.getStream(file)
stream.pipe(endPoint)
return streamToPromise(stream)
})
npm install
npm start
- https://github.com/variety/variety Schema Analyzer for MongoDB
- https://www.npmjs.com/package/mongodb-schema Infer a probabilistic schema for a MongoDB collection.
- https://dbschema.com/download.html
- move to Typepscript (in progress)