Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-126

node.js 0.10 read & write Stream api for GridStore

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • Planning, 2.0
    • Affects Version/s: 1.3
    • Component/s: None

      The current GridStore has a read stream api, no write stream api (just a ad hoc special case with a file desctriptor) , and it's an old Stream (node.js <= 0.8).

      It would be great to have:

      1/ a write stream api that generalizes the writeFile() method

      2/ a node.js 0.10 Readable & Writable Stream api (http://nodejs.org/api/stream.html#stream_api_for_stream_implementors)
      With the new streams it's really easy to implement a Readable and a Writable stream, no need to hack around nasty bugs with pause() and resume(): we just have to implement _read() and _write().

      The first point is really useful: currently we need to store the data in memory or disk before writing it into GridFS, this is a real issue when storing data from a large HTTP file upload for example.

      The second point could simplify the implementation of the first point.

      I understand we still need to keep compatibility with old node.js versions: we could keep the old code (with only a read stream) alongside the new one.

      By the way: https://github.com/mongodb/node-mongodb-native/blob/V1.3.23/lib/mongodb/gridfs/gridstore.js#L321 :
      numberOfChunksLeft is computed but never used in writeFile().

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            trsystran Thomas Riccardi
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: