Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GridFS + Mongoose #5

Open
CodersBrothers opened this issue May 7, 2013 · 5 comments
Open

GridFS + Mongoose #5

CodersBrothers opened this issue May 7, 2013 · 5 comments

Comments

@CodersBrothers
Copy link

Its possible use with "Mongoose", instead of "mongo" module?
Thanks.

@aheckmann
Copy link
Owner

Yes. Mongoose uses the mongodb module. Instructions for accessing it are
here: https://github.com/aheckmann/gridfs-stream#using-with-mongoose

On Tuesday, May 7, 2013, Coders Brothers wrote:

Its possible use with "Mongoose", instead of "mongo" module?
Thanks.


Reply to this email directly or view it on GitHubhttps://github.com//issues/5
.

Aaron
@aaronheckmann https://twitter.com/#!/aaronheckmann

@CodersBrothers
Copy link
Author

Im really new with mongoose and mongo in NodeJS, i cant connect, because seems i need put a model and i cant get collection reference :(

@CodersBrothers
Copy link
Author

My code, but dont work, upload dont return nothing.

var express = require('express'),
     http = require('http'),
     path = require('path'),

     formidable = require('formidable'),
     gridform = require('gridform'),
     mongoose = require('mongoose'),
     Grid = require('gridfs-stream');

    var conn = mongoose.createConnection('mongodb://' + database.server + ':' + database.port + '/'  + database.name);
   conn.once('open', function(err){
    if(!err){
        console.log('Conectado a Mongo!!');
    }else{
        throw err;
    }
});


// Upload
app.post('/upload', function(req, res){

    gridform.db    = conn.db,
    gridform.mongo = mongoose.mongo;    

    var form = gridform();  

    //console.log(form);

    form.parse(req, function(err, fields, files) {

        console.log("File ID:" + files.text.id);
        res.end("File ID:" + files.text.id);

    });

});

@CodersBrothers
Copy link
Author

Imposible, i cant run Express + mongoose + gridform. :(, this is my script http://paste2.org/C2sKGNG3 (I cant save, i cant get)

@MForMarlon
Copy link

@CodersBrothers Did you try putting the gridform.db and gridform.mongo lines inside the conn.once callback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants