Closed prcbass closed 9 years ago
My version of node_modules/mongodb/lib/gridfs/grid_store.js
... looks a bit different. What version of mongodb
do you have installed?
I have version 3.0.3 installed. Is there a newer version I should be using? I see that there is a version 3.0.4 out now.
UPDATE: I installed the newest version of mongo in a copy of my project but I am still getting the same error as far as I can tell
TypeError: undefined is not a function
at GridStore.collection (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/mongodb/lib/gridfs/grid_store.js:513:18)
at GridStore.open (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/mongodb/lib/gridfs/grid_store.js:187:27)
at GridWriteStream._open (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/gridfs-stream/lib/writestream.js:96:14)
at new GridWriteStream (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/gridfs-stream/lib/writestream.js:72:7)
at Grid.createWriteStream (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/gridfs-stream/lib/index.js:42:10)
at /Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/routes/index.js:315:25
at Layer.handle [as handle_request] (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/express/lib/router/layer.js:82:5)
at next (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/express/lib/router/route.js:110:13)
at done (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/multer/lib/make-middleware.js:41:7)
at indicateDone (/Users/sebastianhernandez/Desktop/instagram-project-3/instagram-ads/insta-famous/node_modules/multer/lib/make-middleware.js:45:51)
Strangely enough, when I run db.version()
in my new installation of mongodb I still get 3.0.3. Maybe I didn't do the installation correctly? After unpacking the mongodb .tar I ran mongod --dbpath /path/to/data/folder
using the existing data folder in my project.
I'm not familiar with the monk
package you are using, but i guess the db
-handle you get from it, is not exactly the same as a mongodb
db
-handle.
Could you try passing in a mongo.Db
instance in the Grid
-constructor as seen here?
If this does not solve your issue, please isolate your code further and add it as a test to the project so i can look into it further... thnx
same error type
db.db is not a function
TypeError: db.db is not a function at D:\A imp software file\MEAN developer\expressjs\expresscurd\routes\account.js:24:28 at Layer.handle [as handle_request] (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\layer.js:95:5) at next (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\layer.js:95:5) at D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\index.js:281:22 at Function.process_params (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\index.js:335:12) at next (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\index.js:275:10) at Function.handle (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\index.js:174:3) at router (D:\A imp software file\MEAN developer\expressjs\expresscurd\node_modules\express\lib\router\index.js:47:12)
code var express = require('express'); var router = express.Router();
router.get('/', function (req, res, next) { var db = req.db; var accountTable = db.get('account'); accountTable.find({}, {}, function(errors, accounts) { var data = { accounts : accounts }; res.render('account/index', data); }); });
router.get('/add', function (req, res, next) { res.render('account/add'); });
router.post('/add', function (req, res, next) { var db = req.db; var accountTable = db.db('account'); var account ={ username: req.body.username, password: req.body.password, fullname: req.body.fullname }; accountTable.insert(account, function(errors, result){ res.redirect('/account/add'); }); });
module.exports = router;
I'm using node.js to attempt to store an image in my mongodb. Having required the necessary modules:
I'm trying to write to a stream as such:
When I run this code I get the following in terminal:
With the following error in my browser:
I realize this isn't stack overflow but I feel like I wrote my code as closely as possible to the examples provided within the realm of my project. Any ideas?