Book event, email host, and payments on Keystone

57 views
Skip to first unread message

Tiago Vasconcelos

unread,
Jan 18, 2017, 10:23:43 AM1/18/17
to Keystone JS
Hi guys, i'm doing a restaurant reservation plattform and i'm using Keystone for the backend. I've been using the SydJS and keystone demo for guide and i think things are going along. In a simple way, users browse a list of restaurants in their area, pick one and choose, the day and hour when they want to go to that restaurant. I have the restaurant page done, at the bottom i have a form with some selects for how many people, the day and hours they want to book. 

What i want to do now is that when submiting the reservation a couple of things should happen:

  1. create a DB entry of a reservation
  2. email restaurant asking for availability (update DB with status - email sent)
  3. wait for response, get response from restaurant
    • if positive (update status - confirmed) collect fee €
    • if negative (update status - declinned) recommend similar restaurant
I'm using the contact model and route from the demo website to try and process this but i'm stuck on how can i do things as i described above. I understand that on post, a new DB entry must be created, then with getUpdateHandler fill the initial data. 

Can someone please give me some help on this?

Chris Troutner

unread,
Jan 18, 2017, 2:06:26 PM1/18/17
to Keystone JS
Hey Tiago,

You can use getUpdateHandler, but there isn't very good documentation on it. I use it as little as possible. An alternate method is to use the mode.save() method as described in the KeystoneJS documentation:

Here is an example taken from that page:
var item = new List.model();
item.set({ field1: 'value1', field2: 'value2' });
item._req_user = req.user;
item.save();


Wading into the KeystoneJS waters can be frustrating. If you need additional code examples to follow, you should check out some of the API code I use in ConnextCMS:

If you need help with developing your KeystoneJS app, I'm available for hire at $30USD per hour.

Best of luck to you.

-Chris Troutner

Tiago Vasconcelos

unread,
Jan 19, 2017, 6:59:58 AM1/19/17
to Keystone JS
Thanks Chris, but my actual "problem" is how can i send the email to the restaurant and keep updating the booking model until it's closed and the best possible way to structure the model itself. It falls out from the scope of keystone itself it's more js and development related but i didn't knew where else to post this.


Chris Troutner

unread,
Jan 19, 2017, 4:28:27 PM1/19/17
to Keystone JS
Oh, I didn't get that from the original email. There are probably a myriad of ways to solve that problem. I would probably make repeated REST API calls from the front end to KeystoneJS on the back end. So the front end View would appear as one transaction, but would be constantly firing API calls to KeystoneJS and updating the database model as the user interacts with the View.
Reply all
Reply to author
Forward
0 new messages