Default value in schema field
  • Hi karim,

    I am adding a filed to a preexisting schema on apstrata, I want this filed to have a default value

    <field name="location" type="geospatial" />

    if I added this shall it works?

    <field name="location" type="geospatial" default="0.0,0.0" />

    shall it update the old documents in this schema with "0.0,0.0" as well, the documents that were created before adding this field.

  • Hi Nour,

    You can't initialize a geospatial field using the "default" attribute of a schema.

    Besides, existing documents (i.e. instances of schemas) are never impacted after modifying a schema (new documents only).

  • hi Karim,

    what value the old documents will have for this field.

  • Hi,

    Existing documents won't have this field at all since they are based on the former version of the schema.

    As for new  documents, is the field is mandatory you will have to specify its value when creating the new document. If the field is not mandatory and you do not specify it then your resulting document will not have a geospatial field.

  • Hi,

    The only way to add this field to the old documents is by adding it manullay for every field then, right?

    Edit every old document, add field with its value.


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!