Here are the steps and code changes needed to make this happen. Ecto is also commonly used to map data from any source into Elixir structs, whether they are backed by a database or not. Here is an example: Ecto is commonly used to interact with databases, such as PostgreSQL and MySQL via ( source code ). When the student goes to select their payment option, we read those price quotes and merge them with the payment options available to them, which depend on their location and the campus they plan to attend. Ecto is a toolkit for data mapping and language integrated query for Elixir.From the results of that query, we transform, sanitize, and save "price quotes" that are stored on the student's payment plan record.When a student is admitted, we query Salesforce for the pricing objects available for the student's market and course.So, this is the proposed workflow to the admissions process. I think this works for now, but in the long term, we will need to re-evaluate. This is where the business side of the office tends to spend most of their time, and it is configurable relatively quickly, as opposed to building something myself with code. And since I didn't think it was a good idea to a) hardcode the prices or b) create tables to hold onto prices that can change or build an interface for our finance team to update prices, I decided to store the prices in a table on Salesforce. With this in mind, anticipating change as well as the ability to create custom pricing for each student that is locked at a certain point in time, I decided to try using embedded schemas. They are essentially grandfathered in to the previous pricing. Furthermore, when we do change prices, we have to be careful to honor the pricing promised to students who enroll by a certain date. The pricing also tends to change frequently enough that it's unwise to hardcode it. The pricing for our course offerings varies, as you might expect, by the course, the market, and the method by which you pay, which can be one of the following: upfront, loan, or income share agreement. I work at a school that offers career-changing courses in the form of bootcamps. In the Enrollment Unification project I worked on, I think I found a good use case for embedded schemas. Another benefit of embedded schemas is that if the fields of the data change very often, you don't need to make a lot of table migrations. They are often used as an alternative to associations on another table, with a foreign key and join, which has a number of benefits, including reduced database queries for commonly retrieved associated records. What are Ecto Embedded Schemas?Įmbedded schemas in Ecto are a way of embedding data structures on the same record of a parent schema. I mentioned in my last post the benefits of a nice design pattern, and in this post, I'll expand on that same Enrollment Unification / Admissions Portal project but focus on another aspect of the implementation that I found interesting: the use of Ecto Embedded Schemas.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |