parameters: (self)
return_statement: return projection
docstring: Returns the slice and storage address to return top-level sections for Versions of this ref
  
          Used as:
  
          ::
  
              Version().load({...},oref.part_projection())
  
          **Regarding projecting complex texts:**
          By specifying a projection that includes a non-existing element of our dictionary at the level of our selection,
          we cause all other elements of the dictionary to be unselected.
          A bit non-intuitive, but a huge savings of document size and time on the data transfer.
          http://stackoverflow.com/a/15798087/213042
docstring_summary: Returns the slice and storage address to return top-level sections for Versions of this ref
docstring_tokens: Returns the slice and storage address to return top - level sections for Versions of this ref
function: def part_projection(self):
          """
          Returns the slice and storage address to return top-level sections for Versions of this ref
  
          Used as:
  
          ::
  
              Version().load({...},oref.part_projection())
  
          **Regarding projecting complex texts:**
          By specifying a projection that includes a non-existing element of our dictionary at the level of our selection,
          we cause all other elements of the dictionary to be unselected.
          A bit non-intuitive, but a huge savings of document size and time on the data transfer.
          http://stackoverflow.com/a/15798087/213042
          """
          # todo: reimplement w/ aggregation pipeline (see above)
          # todo: special case string 0?
  
          projection = {k: 1 for k in Version.required_attrs + Version.optional_attrs}
          del projection[Version.content_attr]  # Version.content_attr == "chapter"
          projection["_id"] = 0
  
          if not self.sections:
              # For simple texts, self.store_address() == "chapter".
              # For complex texts, it can be a deeper branch of the dictionary: "chapter.Bereshit.Torah" or similar
              projection[self.storage_address()] = 1
          else:
              skip = self.sections[0] - 1
              limit = 1 if self.range_index() > 0 else self.toSections[0] - self.sections[0] + 1
              slce = {"$slice": [skip, limit]}
              projection[self.storage_address()] = slce
              if len(self.index_node.address()) > 1:
                  # create dummy key at level of our selection - see above.
                  dummy_limiter = ".".join(["chapter"] + self.index_node.address()[1:-1] + ["hacky_dummy_key"])
                  projection[dummy_limiter] = 1
  
          return projection
function_tokens: def part_projection ( self ) : # todo: reimplement w/ aggregation pipeline (see above) # todo: special case string 0? projection = { k : 1 for k in Version . required_attrs + Version . optional_attrs } del projection [ Version . content_attr ] # Version.content_attr == "chapter" projection [ "_id" ] = 0 if not self . sections : # For simple texts, self.store_address() == "chapter". # For complex texts, it can be a deeper branch of the dictionary: "chapter.Bereshit.Torah" or similar projection [ self . storage_address ( ) ] = 1 else : skip = self . sections [ 0 ] - 1 limit = 1 if self . range_index ( ) > 0 else self . toSections [ 0 ] - self . sections [ 0 ] + 1 slce = { "$slice" : [ skip , limit ] } projection [ self . storage_address ( ) ] = slce if len ( self . index_node . address ( ) ) > 1 : # create dummy key at level of our selection - see above. dummy_limiter = "." . join ( [ "chapter" ] + self . index_node . address ( ) [ 1 : - 1 ] + [ "hacky_dummy_key" ] ) projection [ dummy_limiter ] = 1 return projection