Nested pointers are stored differently in mongodb


While going through the code I’ve found that root level pointers are transformed to have shape _p_prop: 'className$objectId'while nested pointers are saved as it is like

pointerProp: {
  __type: 'Pointer',
  className: 'className',
  objectId: 'objectId'

one reason I could think of why we’re doing this way is probably because we know the type of root level attributes from schema.

is there any other reason why we can’t recursively transform nested pointers to have same shape as top level pointers?

It seems nested File, Polygon and GeoPoint types are also not transformed. If I try to transform then in like root level attributes, some tests are failing. is this a design decision?

I think main reason is performance. Root fields are stored in schema in a broad way. For example ıf a field is object, schema field only knows ıts an object and doesnt know whats in it.

For example how will you handle these:

parseObjedt = {
  field1: 'Parse platform',
  field2: 4587,
  field3: {
    innerField:  12,
    innerField2: {
      doubleInnerField: 'kndsfoıfsdoıf',
      someArray: [
          someDeeplevelObject: {
            user: {
              __type: 'Pointer',
              className: '_User',
              objectId: 'objectId'

If you want to transform everyObject, you need to do it recursively which means if you are transforming hundreds of objects with more than 2 level deepnes, this will be your performance bottleneck. But If you really need this you can create a cloud code for saving and fetching the object(s) and make the transformation yourself tough.

Thanks for the answer, That makes sense. Nested pointer queries seems to be working fine, which means query constrains are also transformed to match saved shape.

I think we need to transform all nested Date like types to database’s native types for better database native query support