How can I add field Pointer/Relation to schema via function addField?

Docs says:

addField(name, type, options)
...
type (String)  Can be a (...Array|Object|**Pointer**|**Parse.Relation**)

But Pointer/Relation need targetClass as well, and there are no place for it (in options it does not work).

If you want to name the field “activity” and create a pointer to a class named “Activity”, you can do the following:

addPointer('activity', 'Activity')

I leave it as a fallback. Or is it the only way?

BTW Is there are another fields (except type, targetClass, required and defaultValue) within field described field (sorry for the pun)?

I’m not sure understand your question. Looking at his example may help https://github.com/netreconlab/parse-hipaa/blob/16cbdcf7e72d236a0cb6ed67dec26d7b68475b48/parse/cloud/main.js#L50-L82

So addField does not work with Pointer or Relation as I understand, only with specific addPointer and addRelation. And there is a documentation error about using addField with these types.

P.S. I had to write:

   switch (type) {
      case 'Pointer':
        schema.addPointer(key, targetClass, options);
        break;
      case 'Relation':
        schema.addRelation(key, targetClass);
        break;
      default:
        schema.addField(key, type, options);
    }

Interesting, I’ve never attempted to use addField to add a Pointer or Relation before. @davimacedo @dplewis @Manuel are more familiar with JS than I am. Do any of you see an issue in the documentation? It seems

schema.addField(key, 'Pointer', options);

should work based on what I see…

It does not work because you’d need to also specify the targetClass but it is not currently available in the options. So currently addPointer/addRelation is the right way to go.