gridform
gridform copied to clipboard
GridFS + Mongoose
Its possible use with "Mongoose", instead of "mongo" module? Thanks.
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/aheckmann/gridform/issues/5 .
Aaron @aaronheckmann https://twitter.com/#!/aaronheckmann
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 :(
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);
});
});
Imposible, i cant run Express + mongoose + gridform. :(, this is my script http://paste2.org/C2sKGNG3 (I cant save, i cant get)
@CodersBrothers Did you try putting the gridform.db and gridform.mongo lines inside the conn.once callback?