
Research
/Security News
Coruna Respawned: Compromised art-template npm Package Leads to iOS Browser Exploit Kit
Compromised npm package art-template delivered a Coruna-like iOS Safari exploit framework through a watering-hole attack.
feathers-mongo-collections
Advanced tools
Create a FeatherJS service for managing collections in a MongoDBdatabase.
feathers-mongo-collections works just like a standard FeatherJS service, except for the get/findOne. It uses the collection name as the id value when performing create, update, and remove.
npm install feathers-mongo-database --save
To create an instance of a feathers-mongo-collections service, first connect to your MongoDB database. Then pass the connected database into feathers-mongo-collections.
var feathers = require('feathers');
var feathersMongoColls = require('feathers-mongo-collections');
var MongoClient = require('mongodb').MongoClient;
var dbAddress = 'mongodb://localhost:27017/feathers-tuts';
// Prep the Feathers server.
var app = feathers()
.use(feathers.static(__dirname + '/public'))
.use(bodyParser.json())
.use(bodyParser.urlencoded({extended: true}))
.configure(feathers.socketio())
.configure(feathers.rest());
// Connect to the database.
MongoClient.connect(dbAddress, function(err, db) {
// Create a `feathers-mongo-collections` instance.
app.use('/feathers-tuts/_collections', feathersMongoColls(db))
});
// Start the server.
var port = 8081;
app.listen(port, function() {
// app.use('/api/tasks', require('./services/tasks'));
console.log('Feathers server listening on port ' + port);
});
find() currently accepts no parameters. It simply returns an array of all of the collections in the connected db. It returns data in this format:
[
{
"size": "",
"max": "",
"capped": false,
"name": "users",
"stats": {
"ns": "feathers-tuts.users",
"count": 6,
"size": 1360,
"avgObjSize": 226.66666666666666,
"storageSize": 40960,
"numExtents": 2,
"nindexes": 2,
"lastExtentSize": 32768,
"paddingFactor": 1,
"systemFlags": 1,
"userFlags": 0,
"totalIndexSize": 16352,
"indexSizes": {
"_id_": 8176,
"id_1": 8176
},
"ok": 1
}
},
{
"name": "employees",
"stats": {
"ns": "feathers-tuts.employees",
"count": 0,
"size": 0,
"storageSize": 8192,
"numExtents": 1,
"nindexes": 2,
"lastExtentSize": 8192,
"paddingFactor": 1,
"systemFlags": 1,
"userFlags": 0,
"totalIndexSize": 16352,
"indexSizes": {
"_id_": 8176,
"id_1": 8176
},
"ok": 1
}
}
]
Not implemented
Provide a collection name. If create is successful, the data returned will look like this:
{
"name": "MyCollection"
}
If the collection already exists, the existing collection will not be overwritten. MongoDB doesn't actually require creating a collection before inserting a document. If you insert a document into a collection that doesn't exist, the collection will be created upon insert, so this method is mostly a convenience method for web apps.
For update operations, the collection name replaces the REST id. Pass the current db name as the id, and the new name in the data.
PUT /api/localhost:27017/feathers-tuts/_collections/MyCollection HTTP/1.1
Content-Type: application/x-www-form-urlencoded
name=NewCollectionName
If the update operation is successful, the response will look like this:
{
"name": "NewCollectionName"
}
If the name / id doesn't exist, the following MongoDB error will be returned:
"exception: source namespace does not exist"
If the target name already exists, the following MongoDB error will be returned:
"exception: target namespace exists"
For remove operations, the collection name is used as the REST id.
Successful remove operations will return true.
If the named collection cannot be found, the following MongoDB error will be returned:
"ns not found"
FAQs
MongoDB collections service for FeathersJS.
The npm package feathers-mongo-collections receives a total of 0 weekly downloads. As such, feathers-mongo-collections popularity was classified as not popular.
We found that feathers-mongo-collections demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Compromised npm package art-template delivered a Coruna-like iOS Safari exploit framework through a watering-hole attack.

Company News
As AI accelerates how code is written and shipped, Socket is scaling to protect the software supply chain from the growing wave of attacks targeting open source dependencies.

Company News
Socket is scaling to defend open source against supply chain attacks as AI accelerates software development.