{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]},"settings":""},"next":{"description":"","pages":[]},"title":"Overview","type":"basic","slug":"data-objects-overview","excerpt":"In this chapter you will learn:\n- What are Data Objects\n- What's inside a Data Object","body":"## Chapter contents\n1. [Introduction](#introduction) \n2. [Data Object Fields](#data-object-fields)\n3. [Field Types](#field-types)\n4. [Adding custom (user defined) fields to Data Objects](#adding-custom-user-defined-fields-to-data-objects)\n5. [Summary](#summary) \n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Introduction\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"warning\",\n \"body\": \"Because Data Objects on Syncano are schema based, you'll need to create a Data Class, where you can define a schema for your Data Objects. Creating Data Classes is described in [this chapter](doc:classes-overview).\"\n}\n[/block]\nYou can store data on Syncano using Data Objects. Data Objects are similar to `JSON` objects, that contain key-value pairs defined by you during Data Class creation. All of them also have default attributes defined by Syncano. \n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Data Object Fields\"\n}\n[/block]\nHere's how a simple Data Object representing a book could look like:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"id\\\": 55,\\n \\\"author\\\": \\\"J. R. R. Tolkien\\\",\\n \\\"title\\\": \\\"The Fellowship of the Ring\\\",\\n \\\"text\\\": \\\"Hobbits and stuff\\\",\\n \\\"created_at\\\": \\\"2015-02-05T13:38:33.829340Z\\\", \\n \\\"updated_at\\\": \\\"2015-05-18T21:36:02.410173Z\\\", \\n \\\"revision\\\": 2, \\n \\\"owner\\\": null, \\n \\\"owner_permissions\\\": \\\"none\\\", \\n \\\"group\\\": null, \\n \\\"group_permissions\\\": \\\"none\\\", \\n \\\"other_permissions\\\": \\\"none\\\", \\n \\\"channel\\\": null, \\n \\\"channel_room\\\": null, \\n \\\"links\\\": {\\n \\\"self\\\": \\\"/v1.1/instances/syncano/classes/test/objects/55/\\\"\\n }\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\nApart from `author`, `title` and `text` fields, which you would define when creating a data class, there are several built-in fields, which every object has. They are listed in the table below:\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Field\",\n \"h-1\": \"Type\",\n \"0-0\": \"id\",\n \"0-1\": \"integer\",\n \"1-0\": \"created_at\",\n \"2-0\": \"updated_at\",\n \"3-0\": \"revision\",\n \"3-1\": \"integer\",\n \"4-0\": \"links\",\n \"1-1\": \"datetime\",\n \"2-1\": \"datetime\",\n \"4-1\": \"array\",\n \"h-2\": \"Description\",\n \"0-2\": \"Data Object identifier\",\n \"1-2\": \"Data Object creation date in ISO 8601, UTC date time format with microsecond precision (i.e. 2015-02-13T07:32:05.659737Z)\",\n \"2-2\": \"Data Object latest modification date in in ISO 8601, UTC date time format with microsecond precision (i.e. 2015-02-13T07:32:05.659737Z)\",\n \"3-2\": \"Version of a Data Object. It increments every time a Data Object is updated in any way.\",\n \"4-2\": \"[HATEOAS](http://stackoverflow.com/questions/9192648/hateoas-concise-description) Links.\"\n },\n \"cols\": 3,\n \"rows\": 5\n}\n[/block]\nAs you can see, there are several fields that were not mentioned in the table above:\n- `owner`, `owner_permissions`, `group`, `group_permissions`, `other_permissions` - these fields relate to permissions system on Syncano. You can read about them later in the [Permissions Chapter](doc:permissions)\n- `channel` and `channel_room` - these fields can be used to take advantage of real-time communication features Syncano provides. You can read about the concept in depth in the [Realtime Communication](doc:realtime-communication) chapter.\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Field Types\"\n}\n[/block]\nIn our book example, `author`, `title` and `text` fields are custom and were created by a Syncano user. These custom fields can have several different types:\n\n[block:parameters]\n{\n \"data\": {\n \"h-0\": \"Type\",\n \"h-1\": \"Description\",\n \"h-2\": \"Limit\",\n \"0-0\": \"`string`\",\n \"1-0\": \"`text`\",\n \"2-0\": \"`integer`\",\n \"3-0\": \"`float`\",\n \"6-0\": \"`boolean`\",\n \"7-0\": \"`datetime`\",\n \"8-0\": \"`file`\",\n \"9-0\": \"`reference`\",\n \"10-0\": \"`geopoint`\",\n \"4-0\": \"`array`\",\n \"5-0\": \"`object`\",\n \"5-1\": \"an unordered collection of key:value pairs\",\n \"4-1\": \"an ordered sequence of values\",\n \"0-1\": \"double-quoted Unicode with backslash escaping\",\n \"3-1\": \"Fractions like 0.3, -0.912 etc. Double precision field with up to 15 decimal digit precision\",\n \"6-1\": \"`true` or `false`\",\n \"2-1\": \"Digits 1-9, 0 and positive or negative\",\n \"1-1\": \"double-quoted Unicode with backslash escaping\",\n \"7-1\": \"ISO 8601, UTC date time format with microsecond precision (i.e. 2015-02-13T07:32:05.659737Z)\",\n \"8-2\": \"128mb\",\n \"0-2\": \"128 max character length\",\n \"1-2\": \"32000 max character length\",\n \"2-2\": \"32-bit (signed)\",\n \"3-2\": \"64-bit\",\n \"9-1\": \"Reference to a different Data Object\",\n \"10-1\": \"longitude and latitude\",\n \"8-1\": \"stored as a url\"\n },\n \"cols\": 3,\n \"rows\": 11\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"body\": \"A default value for any field type is `null`. What it means, is that when a Data Object is created and there's no value assigned to a custom property, it's value will be `null`.\"\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Adding custom (user defined) fields to Data Objects\"\n}\n[/block]\nThe custom fields are defined when creating a Data Class that wraps your Data Objects. \n[block:image]\n{\n \"images\": [\n {\n \"image\": [\n \"https://files.readme.io/sfCcsQ0IQzs2QC1VBoZH_Field_types.png\",\n \"Field_types.png\",\n \"1279\",\n \"655\",\n \"#697c9e\",\n \"\"\n ]\n }\n ]\n}\n[/block]\nYou can read more about user-defined field types in the [Data Classes chapter](classes#section-types-of-class-schema-fields).\n\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Summary\"\n}\n[/block]\nYou should have an overview of what Data Objects are and what kind of data types can be stored in Data Objects. It's time to learn the [basics of adding, updating, deleting and listing Data Objects](basics).","updates":[],"order":0,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5735d3f7a430ed22001c5e90","parentDoc":null,"__v":22,"githubsync":"","user":"54774c47f3736008009e9e0c","project":"54774d9af3736008009e9e0e","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Data Objects","slug":"data-objects","order":13,"from_sync":false,"reference":false,"_id":"5735a52431a73b1700887ca0","project":"54774d9af3736008009e9e0e","__v":0,"version":"56a0bd9e3697d80d002ac5e7","createdAt":"2016-05-13T09:57:56.274Z"},"createdAt":"2016-05-13T13:17:43.221Z","version":{"version":"1.1","version_clean":"1.1.0","codename":"Sockets","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["56a0bd9f3697d80d002ac5e8","56a0bd9f3697d80d002ac5e9","56a0bd9f3697d80d002ac5ea","56a0bd9f3697d80d002ac5eb","56b098a43a5b810d00745e3f","56b098da8f7a4f0d0029dd10","56d5a8ecf612b80b00fb69cd","570989853ab43c0e0072b2d6","571006aa10300c0e007f6133","5735a52431a73b1700887ca0","5744b0529e045c0e00b7a7a2","5744b1d0b56d431700d8a4fb","5744b1fb55d65a0e00b436e1","5744b218f9c7411700ce560e","5744b220f9c7411700ce560f","5744b2259e045c0e00b7a7a7","5744b22cf8b79f0e00de6a2d","5744b23155d65a0e00b436e4","5744b242c758290e00fbc235","5744b2569e045c0e00b7a7a8","5756a3f2bb92962900dafe3d","57ee23e81e42900e0014a42f","581c822c98676e0f00d240ef"],"_id":"56a0bd9e3697d80d002ac5e7","project":"54774d9af3736008009e9e0e","releaseDate":"2016-01-21T11:14:38.131Z","__v":20,"createdAt":"2016-01-21T11:14:38.131Z"}}
Overview
In this chapter you will learn:
- What are Data Objects
- What's inside a Data Object