This documentation is not maintained. Please refer to doc.castsoftware.com/technologies to find the latest updates.
CAST supports MongoDB as follows:
- via its com.castsoftware.nodejs extension when the source code language is JavaScript
- via its com.castsoftware.typescript extension when the source code language is TypeScript.
Details about how this support is provided is discussed below.
Objects
Icon | Description |
---|---|
Node.js MongoDB connection | |
Node.js MongoDB collection |
Links
The following links will be generated from a call of the following methods from a collection object:
Link type | Methods |
---|---|
useSelectLink | findOne, findById, where, find, exists |
useDeleteLink | remove, findByIdAndRemove, findOneAndRemove, findByIdAndDelete, findOneAndDelete, deleteOne, deleteMany |
useUpdateLink | update, updateOne, updateMany, findByIdAndUpdate, findOneAndUpdate, findByIdAndReplace, findOneAndReplace, replaceOne |
useInsertLink | insertMany, insert, create |
Code sample
This declaration will create a MongoDB connection and a collection object named "users". A "useSelectLink" between the find function and the collection is also created.
var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/analyzerlauncher', function(err) { if (err) { throw err; } }); // create a Mongoose model userModel = mongoose.model('users', userSchema); function find(req,res){ userModel.findOne(req.params.id, function (err, authorize) {}) }