POSTing

23 views
Skip to first unread message

Russ

unread,
Dec 30, 2013, 2:48:29 PM12/30/13
to taffy...@googlegroups.com
Sorry for all the questions. I'm still trying to wrap my head around some things.

I'm confused with the distinction between Collections and Members & POSTs - or creating new records.

The problem is that I would expect my post function to be in a Member cfc. Say I have a contacts table, so I would have a contactsCollection and contactsMember cfc.

I would expect to have my put/post/delete methods be inside of the contactsMember.cfc. However, the uri for this is: taffy:uri="/contacts/{id}"

When I do a post to create a record I don't know what the id will be, because it is generated automatically by the DB.

I could get around this by putting my post method inside the contactsCollection.cfc, but that seems to go against the logic of a collection working on many records and a member working on a single/specific record.

What is best practice for this?

Thanks,

Adam Tuttle

unread,
Dec 31, 2013, 8:46:13 AM12/31/13
to taffy...@googlegroups.com
I see what you're saying, but I just think of the POST as operating on the collection: It's adding to it. Think of it like array.push() in JavaScript.

Best practice is to POST when you don't know the id of the record you're creating, or PUT if you're creating but you do know the id (i.e. because it's a natural key like a ssn or something).

I wouldn't recommend getting too hung up on details like this. It's just a single method in one of two possible CFC's. :o)

Adam


--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages