There doesn't appear to be a way to delete a GridStore file created in an alternate root collection

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      gem version 0.18.3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Using the GridStore.open and GridStore.new methods, it's possible to specify a :root option, which allows one to change the default root collection where a file will be stored. I can't see a way through the GridStore.unlink class method to unlink a file in an alternate root collection.

      It seems the only way to actually accomplish the deletion is to call GridStore.new(db, name, 'r', :root => 'root_name') and do what the 'unlink' method is doing "by hand."

      I've included a little script that shows what i'm talking about.

      Perhaps the following would be an improvement?

      def self.unlink(db, *names)
      opts = names.last.kind_of?(Hash) ? names.pop : {}

      names.each do |name|
      gs = GridStore.new(db, name, 'r', opts)
      gs.send(:delete_chunks) # does this work in 1.9 ?
      gs.collection.remove('_id' => gs.files_id)
      end
      end

      Then you could do:

      > GridStore.unlink(db, 'filename1', 'filename2', 'filename3', :root => 'alt_root')

      Admittedly, the 'r' is kind of ugly, but this would have the desired effect and would also allow the method to keep its varargs signature.

            Assignee:
            Kyle Banker (Inactive)
            Reporter:
            Jonathan Simms
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: