Check out a free preview of the full Production-Grade Angular course:
The "Creating a CRUD Service" Lesson is part of the full, Production-Grade Angular course featured in this preview video. Here's what you'd learn in this lesson:

Lukas continues to develop the mock widget service started in the previous segment by refactoring the component and the controller to allow the creation, update, and deletion of widgets.

Get Unlimited Access Now

Transcript from the "Creating a CRUD Service" Lesson

[00:00:00]
>> Even with all of my talking in my commentary that took maybe less than 10 minutes to do that, and, like I feel pretty good about myself. Honestly, if somebody said, what did you do today, Lukas? I would say well. I basically did about a week's worth of work on a workshop with all my buddies and it was cool.

[00:00:28] And so, again, when you get in, you start to abstract your complexity out to the things that matter. You can hyper accelerate your ability to build the things that simply do not change from one domain model to the other. Rest being a very consistent thing within your development experience.

[00:00:57] And so what I can do here is I'm going to just. From the application itself or from the code, cuz I'm not gonna type this all out, but I'm going to just paste this in, so we can see it. And if you have any questions about what I have done, then we can just reference the repo for that.

[00:01:25] So what I'm gonna do here, I'm going to paste these in and what I've done is mock widgets. So pretty much the same exact thing. And now when I wanna find one, I'm just using the Ray high order functions. Create, update, delete the differences with create. Let me fix that.

[00:01:51] What I'm doing is I'm creating a new object using an immutable function and then I'm just adding in like a uuid to it, so that I can reference it later. So I'm gonna save this. And I believe if I'm not mistaken, that this is going to not like this at all.

[00:02:13] The reason being is that and I'm not for sure why they did, so they're using a data transfer object by default. We're not gonna do that. Although you could and there are reasons for that, I suppose. But just to keep it simple going to switch this and I believe the reason, I feel like this is a bit of a carryover from I saw this a lot in Java many years ago, I think that the transfer object to create an item and then to update an item.

[00:03:04] They're slightly different. The big difference being that one has an id and one doesn't. So actually now I'm curious. So This is not super intuitive. So if anybody figures that out, feel free to shoot that into chats, and then Mark can take me to school about why that is happening.

[00:03:28] So let's save this. Let's hop back into our browser. And let's refresh this, and if I go to widgets now, this is how we will know, This work. This might have actually been an issue with the fact that we're not actually handling this in the client side. Let me refresh.

[00:03:58] Let's see what happened here. One more time. I know what happened ,don't worry about it. That widget service. All right, so that's working. This is the problem. Within here, Create widget. And I hope at some point that Somebody is looking at this and they're saying that my goodness Lukas is typing a lot of the same stuff over and over.

[00:05:22] Or it seems like he's typing it here and then it's happening over here. Let's save this Back into Let's go Needs double checking make sure I don't have any errors, Good, nothing there, nothing there, I feel like I can close these, And let's figure out, Well, I'm not gonna worry about this too much because it's not contingent on the point that I want to make.

[00:06:23] This is something I might fix on the break but Does make me wonder. Well, regardless, let me stop here. And let me just raise the question. Does anybody based on what I've done have any questions or commentary about the fact that I'm basically writing angular and node and calling it Nest?

[00:07:01] How does everybody feel about that? Any opinions? When I saw it on I was like Holy moly, like that's amazing. Yeah, I'm getting some thumbs up. So funny story. If you went and looked in the the Git history of Nist. I was trying to get the Nest CLI to work and it just wasn't working.

[00:07:25] And so I filed this huge bug report. I'm like, I typed this in and like this is supposed to happen. It doesn't happen. And Camille who wrote Nist he wrote back end he was like, in order to run our CLI, its Nest, whatever the command is. And I had written the whole thing using ng.

[00:07:41] And so I basically submitted a big bug report against Nest that like ng, which is the Angular CLI command was not working. So, it just was so close. I just felt like I was working in Angular. So that is how to rapidly build an API. And let me show you one more trick before we move on.