i am able to run mongodb in my apple console, and vim
the mongo.log
right now, i just want to open up the mongodb console so that i can test queries in the console just like the examples in http://www.mongodb.org/display/DOCS/Tutorial
at the moment, the cursor is not returned:
> mongodb
all output going to :/usr/local/var/log/mongodb/mongo.log
and the cursor is not returned. i was expecting the cursor to be returned to so i can do the following :
> mongodb
all output going to :/usr/local/var/log/mongodb/mongo.log
> test = {name : "bouncingHippo"}
> db.family.save(test)
> "ok"
What am i doing wrong? i am using mongoose
I'm not entirely clear which console you are getting this output from, as the Node console won't return anything usable if you just enter mongodb
.
If what you are trying to do is just launch a MongoDB console, you will need to first launch the mongod
process and then attach to that process with the MongoDB console. The MongoDB console is called mongo
. In the simplest test, you can launch mongod
from one terminal window and then mongo
from another. In the terminal window that is running mongo
you can then work through the examples in the tutorial . Your pseudo code would then look like:
MongoDB shell version: 2.2.1
connecting to: 127.0.0.1:18070/test
> test = {name : "bouncingHippo"}
{ "name" : "bouncingHippo" }
> db.family.save(test)
If you are trying to use Mongoose for the pseudo code you have in your question, it would be more like the following from the Node console (assuming Node.js and Mongoose are installed)
var mongoose = require('mongoose');
var db = mongoose.createConnection('mongodb://localhost/test');
var testSchema = new mongoose.Schema({
name: String
})
var Test = db.model('Test', testSchema)
var test = new Test({ name: 'bouncinghippo' })
test.save()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.