I'M_DEVELOPERπŸ‘¨β€πŸ’»
15 subscribers
12 photos
3 videos
1 link
HELLOπŸ™‹β€β™‚οΈ , Welcome to my channel πŸ’«
I AM BACKEND NODE JS DEVELOPER πŸ‘¨β€πŸ’»
Download Telegram
create schema hw4;

create table hw4.cars (
id serial primary key,
model varchar(255) not null,
price int not null,
count int default 0
);

--
--

insert into hw4.cars(model,price,count) values
('BMW',10000,50),
('ROLLS ROYCE',20000,10),
('TOYOTA',8000,1000),
('MERCEDEZ',1000,40),
('SUPRA',12000,15);

select * from hw4.cars;

--user create

create table hw4.users(
id serial primary key,
fullname varchar(255),
balance int not null
);

insert into hw4.users(fullname,balance) values
('user1',100000),
('user2',200000),
('user3',80000),
('user4',10000),
('user5',120000);

-- first function...

create or replace function get_price_car(min_price int)
returns table(id int, model varchar(255), price int, count int)
language plpgsql
as
$$
begin
return query
select
c.id,
c.model,
c.price,
c.count from hw4.cars as c
where c.price > min_price order by price ASC;
end;
$$;

select * from get_price_car(8000);

-- second function...

create or replace function get_car_id(car_id int)
returns text
language plpgsql
as
$$
declare car_list text;
begin
select concat(
'id: ', c.id,
', model: ', c.model,
', price: ', c.price,
'. count: ', c.count)
into car_list
from hw4.cars as c
where c.id = car_id;
return car_list;
end;
$$;

select * from get_car_id(1);

--procedure

create or replace procedure buy_car(car_id int, car_count int, user_id int)
language plpgsql
as
$$
declare
car_price int;
car_count_available int;
user_balance int;
begin
select price, count into car_price, car_count_available
from hw4.cars
where id = car_id;

if car_price is null or car_count_available is null then
raise notice 'mashina topilmadi';
rollback;
return;
end if;

select balance into user_balance
from hw4.users
where id = user_id;

if user_balance is null then
raise notice 'foydalanuvchi topilmadi';
rollback;
return;
end if;

if user_balance < car_count * car_price then
raise notice 'foydalanuvchining balansida yetarli pul topilmadi';
rollback;
return;
end if;

if car_count_available < car_count then
raise notice 'mashinadan buncha emas';
rollback;
return;
end if;

update hw4.cars
set count = count - car_count
where id = car_id;

update hw4.users
set balance = balance - car_count * car_price
where id = user_id;

select balance into user_balance
from hw4.users
where id = user_id;

if user_balance < 5 then
raise notice 'foydalanuvchining balansida minimal summa 5 som dan kam';
rollback;
return;
end if;

commit;

raise notice 'buyurtma muvaffaqiyatli amalga oshirildi. % ta mashina sotib olindi', car_count;
end;
$$;

call buy_car(1,2,1);
πŸ”₯6πŸ‘2πŸ‘1πŸ‘Œ1πŸ†’1😘1
Kodingda try bor-u, lekin hayotingda catch ishlamayapti. Xatolarni toβ€˜gβ€˜rilash oβ€˜rniga, ularni "feature" deb nomlab qoβ€˜yayotgan backendchisan. Katta loyihalar qilishni orzu qilasan, lekin hozircha faqat res.send("Hello World") bilan yuribsan.

Sen oβ€˜zingni zoβ€˜r deb bilasan, lekin MongoDB'dagi dokumentlar sendan mustahkamroq qaror qabul qiladi. Frontendni yomon koβ€˜rasan, chunki sen qilgan API-larga hech kim request yubormaydi. Aslida esa backendchilar ham frontendchilar kabi "loading..." holatida yashaydi.

Xoβ€˜jayin, sen senior boβ€˜lishni orzu qilasan, lekin GitHub commitlaring "Initial commit" bilan tugagan. Agar sening dasturlash yoβ€˜lingni "ping" qilib tekshirsak, request timeout berib ketadi.

Lekin sendan yaxshi backendchi chiqadi!"
🀣2πŸ€·β€β™‚1πŸ‘1πŸ”₯1😁1πŸ“1
😠Roast me as hard as you can based on everything you know about me. Don’t hold back even a little bit. I can take it all. In uzbek
Bu so'rovga nisbatan chatgpt javobi πŸ’€πŸ‘†
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ”₯3πŸ‘¨β€πŸ’»2❀‍πŸ”₯1πŸ‘1
I'M_DEVELOPERπŸ‘¨β€πŸ’»
https://youtu.be/itkUJSYrg1U?si=Mdc0tFlSjPGui1jt
Assalomu alaykum ancha manfaatli boβ€˜ldi hammaga ko'rishni tavsiya qilaman
πŸ”₯3πŸ‘2πŸ‘1😍1
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ‘5πŸ”₯1πŸ₯°1πŸ‘1😘1
Ramazon oyi barchamizga barokatli boβ€˜lsin.
Ramazon muborak yaqinlarimπŸŒ•
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸŽ‰4πŸ‘2❀1❀‍πŸ”₯1⚑1πŸ₯°1🀩1πŸ•Š1πŸ’‹1πŸ˜‡1
Qachonki mukammal senior dasturchi boβ€˜lganingda...
πŸ”₯3😁2πŸ’‹1
Qizig'i shu oy yaqinda yangi chiqgandida bugun to'lishga yaqin (#umr oβ€˜tyapti...) !
⚑4πŸ”₯1πŸ˜‡1πŸ’˜1
Og'ir damlar koβ€˜pga bormaydi
Ammo og'ir damlar ichida qolgan bardoshli insonlar koβ€˜pga boradi
...)
πŸ‘4πŸ”₯3⚑1πŸ’‹1
#esda qolarli kunlardan...)🫠
πŸ”₯4⚑2πŸ‘2❀‍πŸ”₯1
#bahor...)
πŸ”₯2⚑1πŸ‘1πŸ•Š1
Media is too big
VIEW IN TELEGRAM
πŸ”₯3πŸ‘1