benoror / ember-airtable

Boilerplate for quickly prototyping apps with Airtable, Node & Ember
https://medium.com/@benoror/creating-an-ember-addon-for-airtable-api-d9e38d7bef97#.33q0r7hhm
MIT License
22 stars 4 forks source link

Table query always pluralized & fields not saving #6

Open delusioninabox opened 6 years ago

delusioninabox commented 6 years ago

Hi! I've having some trouble with this addon. (I'm also fairly new to Ember, so I might be doing something wrong here.)

1) The query to the airtable always pluralizes the name. The table I wanted to access was just named portfolio, but the request always went as portfolios. (Model name in Ember was also singular) I had to change the table name to match for it to work, but it would be nice to allow the table name to be singular.

screenshot at feb 16 18-38-41 screenshot at feb 16 18-35-07

2) Once I finally got data, Ember was only saving the id and none of the fields.

Model: export default DS.Model.extend({ title: DS.attr('string'), description: DS.attr('string'), attachments: DS.attr('[]'), });

Route: model() { return this.store.query('portfolio', {}); }

I tried specifying the fields and without, but the title, description, or attachments never seem to save. I tried console logging in the serializer and everything looks fine except for where it returns -- for some reason the field values aren't in the attributes with the model object type and id. 😬

I'm not sure what I might be doing wrong, so help would be appreciated!! 🙏 Thank you!

benoror commented 6 years ago

The query to the airtable always pluralizes the name

Actually I implicitly decided that the adapter should follow REST-ish resources names (kind of following Rails ActiveRecord conventions), therefore a table name should be plural always.

Once I finally got data, Ember was only saving the id and none of the fields.

A similar thing goes for table attributes naming. You have to specify camelCase both in the models and in Airtable, as far as I remember 🙈

@delusioninabox Laura, can you please add a PR to reflect both things in the README, would be greatly appreciated 😄

delusioninabox commented 6 years ago

@benoror Ohhh, okay, that makes sense!

I'll update the README for noobs like me. 😉 Thanks!

benoror commented 6 years ago

@delusioninabox no worries, my bad for assuming this was obvious. Thanks in advance, cheers!

benoror commented 6 years ago

@delusioninabox by the way, I would love to know how are you using this addon :)

delusioninabox commented 6 years ago

@benoror Added to my PR that also updated Ember.inflector. 😄

Absolutely! I wanted to practice more with using Ember and Ember data, and my husband also wanted to update his art portfolio, so I'm killing one bird with one stone. His previous was with WordPress, but he hated updating it, so just being able to plop a title and attachment to a field in AirTable was a lot easier and faster for him. (Also since this is so simple it loads faster than WordPress. So...bonus. 👌)

I was looking for a way to create a sort of database without having to code a backend and saw your post on Medium. Helped a lot and was good inspiration! 😀 So thanks!

benoror commented 6 years ago

@delusioninabox awesome, thanks!