# Ember data plain array attribute

**URL:** <https://discuss.emberjs.com/t/ember-data-plain-array-attribute/16529>\
**Category:** Ember Data\
**Created:** [May 8, 2019, 8:35pm UTC](https://discuss.emberjs.com/t/ember-data-plain-array-attribute/16529 "2019-05-08T20:35:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mario.gomez](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mario.gomez](https://discuss.emberjs.com/u/mario.gomez)\
**Post date:** [May 8, 2019, 8:35pm UTC](https://discuss.emberjs.com/t/ember-data-plain-array-attribute/16529/1 "2019-05-08T20:35:05Z")

</div>

How can I model an object that has a plain array of strings? If I do the following it shows me the emails but when modifying their value they are not updated.

The server sends/receives the following data:

```
   "data":
	[
		{
			"attributes" : {
				"id":1,
				"name":"Jhon",
				"emails":["jhon@gmail.com","jhon@other.com"]},
				"relationships": (,..}
			}
		}

		...

```

Model:

```
export default Model.extend({
	id: attr('string'),
	name: attr('string'),
	emails: attr()
})

```

Template:

```
{{#each model.emails as |email|}}
	<input type="text" value={{email}}>
{{/each}}

```

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [May 8, 2019, 8:46pm UTC](https://discuss.emberjs.com/t/ember-data-plain-array-attribute/16529/2 "2019-05-08T20:46:07Z")

</div>

First of all I’d change the transform in your model from “boolean” to nothing:

```auto
emails: attr()

```

You could also write a custom transform if you wanted to do anything special.

Ember Data won’t track property changes for “complex” data like that. If you want it to you’ll either need to use a relationship or look into an addon like [ember-data-model-fragments](https://github.com/lytics/ember-data-model-fragments)

---

<div class="post-metadata">

**Author:** ![mario.gomez](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mario.gomez](https://discuss.emberjs.com/u/mario.gomez)\
**Post date:** [May 8, 2019, 9:23pm UTC](https://discuss.emberjs.com/t/ember-data-plain-array-attribute/16529/3 "2019-05-08T21:23:41Z")

</div>

OK thank you, the boolean attribute was an error when writing the question. I understand that I have to use a relationship. How do I send and receive the data in the format expected by the server? I have to create a serializer?

---

<div class="post-metadata">

**Author:** ![amiel](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/amiel/32/15097_2.png) [@amiel](https://discuss.emberjs.com/u/amiel)\
**Post date:** [May 14, 2019, 6:47pm UTC](https://discuss.emberjs.com/t/ember-data-plain-array-attribute/16529/4 "2019-05-14T18:47:14Z")

</div>

You can totally use a simple array. Having `attr()` with no transform works just fine, although we use a transform partially to have self-documenting code, and to default to an empty array.

```
// app/transforms/array.js
import DS from 'ember-data';

export default DS.Transform.extend({
  deserialize(serialized) {
    return serialized || [];
  },

  serialize(deserialized) {
    return deserialized;
  }
});

```

With this, you can use:

```
emails: attr('array'),

```
