![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
mongoose-repl
Advanced tools
Readme
A Mongo REPL with the full power of Mongoose.
If you're using the Mongoose ODM to keep your MongoDB code from descending into schema-less chaos, it can be a pain to fall back to the barebones Mongo shell when you want to interact with your data.
mongoose-repl
registers your schemas and exposes the resulting models in an interactive REPL, so you can findById
and populate
to your heart's content. You'll never have to type ObjectId
again! Oh, and did I mention it interprets CoffeeScript?
$ mongoose --schemas examples/schemas.coffee localhost/test
> Dog.findById('520bb7baa4e06dc4e9000001').select('enemy name').populate('enemy')
{ name: 'fido',
enemy: { name: 'fluffy', _id: 520baec9d61fae3ee6000001, __v: 0 },
_id: 520bb7baa4e06dc4e9000001 }
> Cat.findById _.enemy._id
{ name: 'fluffy', _id: 520baec9d61fae3ee6000001, __v: 0 }
npm install -g mongoose-repl
To connect to a Mongo instance, simply pass in a MongoDB connection string:
$ mongoose localhost/test
Connecting to: localhost
Using db: test
No models loaded
>
Now you have access to the Mongoose connection object:
> conn.host
'localhost'
> conn.name
'test'
> conn.db
{ domain: null,
_events:
{ close: [Function],
error: [Function],
...
Notice that no models were loaded, so the REPL isn't very useful yet. In order for mongoose-repl
to give you access to Mongoose models, you have to first tell it about your schemas. Create a module that exports a mapping from schema names to schemas, like so:
$ cat examples/schemas.coffee
{Schema} = require 'mongoose'
module.exports =
Cat: new Schema
name: String
Dog: new Schema
name: String
enemy: { type: Schema.Types.ObjectId, ref: 'Cat' }
Now you can load these schemas into the REPL using the --schemas
(-s
) option, which will register them as Mongoose models:
$ mongoose --schemas examples/schemas.coffee localhost/test
Connecting to: localhost
Using db: test
Loaded models: Cat, Dog
> Cat.modelName
'Cat'
This is where things get awesome. Now you can query models just like you do in Mongoose:
> Dog.findOne().populate('enemy')
{ name: 'fido',
enemy: { name: 'fluffy', _id: 520baec9d61fae3ee6000001, __v: 0 },
_id: 520bb7baa4e06dc4e9000001,
__v: 0 }
The special variable _
holds the value of the last expression, so you can use it in further queries:
> Cat.find name: _.enemy.name
[ { name: 'fluffy', _id: 520baec9d61fae3ee6000001, __v: 0 } ]
FAQs
A Mongo REPL with the full power of Mongoose
The npm package mongoose-repl receives a total of 2 weekly downloads. As such, mongoose-repl popularity was classified as not popular.
We found that mongoose-repl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.