4

I'm using the current application stack:

node.js, mongodb, express (for node.js), and mongoose (for node.js ... gives me orm capabilities)

I'm getting used to everything and have the regular CRUD stuff working. However, I can't figure out how to store binary/gridfs/BSON stuff in mongo and retrieve it.

Can someone give me an example using node.js/mongo/mongoose or know of a good one or know if its possible?

Travis
  • 7,391
  • 12
  • 43
  • 52
  • 1
    Looks like mongoose depends on node-mongodb-native which can store binary data files I guess according to its github: https://github.com/christkv/node-mongodb-native Seems like mongoose just needs some good wrapper functionality for files to access this? – Travis Dec 22 '10 at 20:14
  • I think thats probably what I'll do since I'm using amazon ec2 ... ill probably just store them in s3 and store their locations in the database – Travis Dec 22 '10 at 21:49
  • 1
    I'm now significantly happier and using another one of TJ's libraries for node: https://github.com/LearnBoost/knox ... for storing them to s3 ... way better than putting them into mongo – Travis Dec 22 '10 at 22:30

2 Answers2

2

According to Guillermo Rauch from the mongoose project, adding support to GridFS is not their priority right now (http://groups.google.com/group/mongoose-orm/browse_thread/thread/1bce50d90680d502)

Mentioned this here, so that somebody interested may pickup the task and hack GridFS support into mongoose.

shashi
  • 21
  • 2
2

https://github.com/christkv/node-mongodb-native/blob/master/examples/types.js#L30 lists down how you can add BSON Binary type using the node-mongodb-native.

Samyak Bhuta
  • 1,256
  • 7
  • 20
  • You can also use https://github.com/tdegrunt/mongodb-rest to get the RESTfulness out-of-the-box !! – Samyak Bhuta May 12 '11 at 10:39
  • How do you retrieve the binary value. I'm converting a python app that does this with ease and no hassle, but in Node.JS it's not working. It says it's of type 2 if you just send the records that come out of the driver to the client. If you console.log them you get binary data. I don't see many examples in the tests that have how to do it. – Justin Thomas Nov 07 '11 at 20:25