Recently I’ve been trying to incorporate infrastructure as code in my project at the early stages so that it increases the efficiency, productivity, and confidence when it comes to deployment and testing. While working on setting up the IaC, I decided on three different stages which are development, staging, and production.
One issue that I have stumbled on is when I do some changes related to the resources that I have defined in pulumi and their configurations, running pulumi preview
is not enough to make sure that everything is working properly. I might have defined my resources correctly, and the…
In this article, we will talk about the different topics that will lead us to understand better what thenew
keyword does in JS.
__proto__
property and its role when it comes to objects and the prototypal chainingprototype
and __proto__
__proto__
and prototype
and the prototypal chainnew
keyword and how do the different pieces relate to itThe tweet which you can see below is asking whether all Objects have the…
Most probably you’re reading this because you are probably developing a blog using Django. It’s something I actually was searching all over the internet 2 years ago when I started learning python, and couldn’t find examples online. Took me weeks, but I finally figured out, and was lucky enough to find a StackOverflow question that is asking the same question and I could answer it perfectly.
You’ll just need two models. One for the Post and the other would be for the Images. Your Images model would have a ForeignKey to the Post model:
class Post(models.Model): user = models.ForeignKey(User) title…
Fractals are great, and I started using them in project Rawag, but after updating the old code for a speed performance update, I needed to return a fractal in a custom response. The reason behind this was I only wanted to load specific data for a JSON response, because returning a fractal for a whole Collection the loading time is very slow, so I needed a smaller JSON response.
I’m using laravel-fractal https://github.com/spatie/laravel-fractal
So instead of returning a collection with nested collections:
return $this->response()->collection($reservations, new ReservationTransformer)->setStatusCode(200);
I can return a custom array with only the ‘Fracteled’ data that I need, which in this case just the property.
return [
"id" => $reservation->id,
"reference" => $reservation->reference,
"property" => (new PropertyTransformer)->transform($reservation->property)
];