快速开始
示例-构建一个租房系统

基于 ProtonBase 能力构建一个租房系统

背景

大家在旅行时最为关注的问题之一就是住宿,国外的民宿互联网模式,以 Airbnb 为代表,已经彻底改变了酒店业。许多游客更愿意选择预订 Airbnb 而非传统酒店,而在国内,美团、飞猪等平台也有大量的民宿资源。 作为快速入门系列的第一篇文章,本教程将向您展示如何利用 ProtonBase 支持上层应用,构建一个完善的租房系统,该系统包含以下主要功能:

  • 发布房源
  • 修改房源
  • 搜索房源

数据集

本系列教程以 Airbnb 在中国香港地区的房源数据为基础(截至 2023 年 9 月),来演示民宿平台的构建 http://insideairbnb.com/get-the-data/ (opens in a new tab)

环境设置

  1. 创建一个新的 Warebase,操作详情参考 10 分钟快速入门
  2. 连接 Warebase ,操作详情参考 连接 Warebase
  3. 创建房源数据表(listings):
CREATE TABLE IF NOT EXISTS listings(
    "id" BIGINT NOT NULL PRIMARY KEY, -- 房源ID
    "listing_url" TEXT, -- 房源详情页面 URL
    "name" TEXT, -- 房源名称
    "price" DOUBLE PRECISION , -- 价格,单位 HK $
    "beds" INT, -- 床数量
    "amenities" JSONB, -- 配套设施tag,半结构化数据
    "has_availability" TEXT, -- 房源是否空闲
    "host_verifications" JSONB, -- 房东验证方式
    "number_of_reviews" INT, -- 总评论数
    "number_of_reviews_l30d" INT, -- 过往30天评论数
    "longitude" DOUBLE PRECISION, -- 经度
    "latitude" DOUBLE PRECISION, -- 纬度
    "description" TEXT -- 房源描述
);
  1. 导入测试数据
INSERT INTO listings(id, listing_url, name, price, beds, amenities, has_availability, host_verifications, number_of_reviews, number_of_reviews_l30d, longitude, latitude, description) values
(17891, 'https://www.airbnb.com/rooms/17891', 'Rental unit in Hong Kong Island · ★4.76 · Studio · 1 bed · 1 bath', 1400.0, 1.0, '["TV", "AC - split type ductless system", "Fire pit", "Coffee maker", "Refrigerator", "Elevator", "Outdoor furniture", "Kitchen", "Pets allowed", "Washer", "Wifi", "Dedicated workspace"]', 't', '["phone", "work_email"]', 73, 0, 114.14988, 22.28327, 'Gorgeous and spacious loft, in the best location. Also available for Commercial Shoots and Longer term rentals.<br /><br /><b>The space</b><br />The apartment has been featured on the cover of numerous Design Magazines, and is listed as one of Airbnb''s Top 40 Rentals Worldwide. <br /><br />Longer Term / Monthly rates available. <br />Also available for Commercial Shoots, inquire for day rates. <br /><br />Large & light-filled, designer open floor plan (800 sqf), fully furnished, with ultra-modern, open kitchen , available for short & long term. <br /><br />Includes:<br />- full kitchen (stove top, oven)<br />- fully equipped workstation with wi-fi & printer<br />- balcony & large windows<br />- queen size bed<br />- walk-in wardrobe<br />- 10 ft dining table perfect for entertaining<br />- polished concrete floors<br />- walk-in rain shower<br />- fresh towels & linens <br /><br />Check In Time: 3pm<br />Check Out Time: 12noon<br /><br /><br />Location:<br />The flat is between SOHO an')
,(505456, 'https://www.airbnb.com/rooms/505456', 'Rental unit in Sheung Wan · ★4.68 · 1 bedroom · 2 beds · 1 bath', 900.0, 2.0, '["Microwave", "Books and reading material", "Hair dryer", "Carbon monoxide alarm", "Bay view", "Refrigerator", "Elevator", "Bed linens", "Dishes and silverware", "Hangers", "Pack \u2019n play/Travel crib", "Host greets you", "Dining table", "Shampoo", "Children\u2019s dinnerware", "Wifi", "Coffee", "Stove", "HDTV with standard cable, Netflix, premium cable", "Ocean view", "Air conditioning", "Extra pillows and blankets", "Free street parking", "Free dryer \u2013 In unit", "Hot water", "Clothing storage: closet and dresser", "Heating", "Toaster", "Long term stays allowed", "Essentials", "Coffee maker", "Ethernet connection", "Kitchen", "Pets allowed", "Dedicated workspace", "Smoke alarm", "Wine glasses", "Exercise equipment: yoga mat", "Shower gel", "Cleaning products", "Paid parking off premises", "Iron", "Drying rack for clothing", "Cooking basics", "Hot water kettle", "Room-darkening shades", "Dove body soap", "Dove conditioner"]', 't', '["email", "phone"]', 267, 1, 114.1489, 22.28543, 'Quiet and Bright apartment in a green and upcoming neighborhood with walking distance cafe,bakery, restaurants and art galleries.<br /><br /><b>The space</b><br />This bright and cozy apartment is located on the charming street, Po Hing Fong.<br />In the heart of Sheung Wan, Hong Kong''s oldest district. <br /><br />Just below you will find Hollywood Road and the historic Man Mo Temple, chic cafes, a famous cheese and wine cellar, antique stores and the city''s art galleries. <br /><br />A 5-minute walk to downtown Central where a huge variety of exciting bars and <br />restaurants, including traditional Dim Sum and local Chinese street food, await. <br /><br />Convenient transportation right at the doorstep: <br /> Taxis,<br /> 7minute walk to Sheung Wan MTR and Central al MTR<br />  5-minutes walk to the tramway <br /><br />Apartment includes:<br />queen size bed with full linen<br />Towels<br />Sofa with pull-out bed<br />Air conditioning<br />Fully equipped kitchen with gas stove, mi')
,(540892, 'https://www.airbnb.com/rooms/540892', 'Rental unit in Sheung Wan · ★4.0 · 1 bedroom · 3 beds · Half-bath', 950.0, 3.0, '["Smoke alarm", "Fire extinguisher", "Hair dryer", "Elevator", "Air conditioning", "Iron", "Hangers", "Lock on bedroom door", "Kitchen", "Pets allowed", "Shampoo", "Washer", "Wifi"]', 't', '["email", "phone"]', 10, 0, 114.15241, 22.2858, 'This is  largest room in this apartment with queen sized Bed and extra space for  a bunk bed or extra mattress settings inside the room floor.<br /><br />The shared bath room, Kitchen and dinning area is also  spacious . Very good location.<br /><br /><b>The space</b><br />The Space  <br />A 9 s meeter  large   double  private bedroom located in Sheung Wan where it is one of the most popular locations in Hong Kong. This room is one of the four rooms that I rent out in a 3,000 square feet large apartment. It comes with a double bed and a single bed with air conditioning. There is a deluxe bathroom available that is shared with other guests. There is wardrobe, bookshelf and WIFI is also available. I would recommend this room for family or friends that are traveling in a group of 3-4  people/ Family. <br />The Neighborhood <br />The apartment is within walking distance to many of the great markets in Sheung Wan (Dry Sea Food Market, Antique Market, Gallery etc). There are plenty restauran')
,(646645, 'https://www.airbnb.com/rooms/646645', 'Hostel in Hong Kong · ★4.53 · 1 bedroom · 1 bed · 3 shared baths', 280.0, 1.0, '["Smoke alarm", "Essentials", "Fire extinguisher", "Self check-in", "Hair dryer", "Keypad", "Air conditioning", "Iron", "Hangers", "Kitchen", "Pets allowed", "Shampoo", "Smoking allowed", "Hot water", "Wifi"]', 't', '["email", "phone"]', 37, 0, 114.16433, 22.32532, '<b>The space</b><br />Welcome to Room Laura! <br />Immerse yourself in the cultural layers of Shamshuipo where you could experience the unique HK authenticity in every detail. <br /> <br />- 10 minutes walk from prince Edward  MTR station  <br />- FREE WIFI  <br />- Air-con inside your room so you could adjust your own room temperature  <br />- shared hair dryer, iron so you will walk out fresh and well-groomed!  <br />- kitchen with fridge, microwave, stove and small oven  <br />- smoking area at the balcony  <br />- private toilet and shower area <br /> <br />- play pingpong, enroll in a wing-chun/ pilates class or find out what''s happening in town with the locals and be part of our (website hidden)/wontonmeen <br /> <br />- laundry is just downstairs! how convenient!  <br />- buy your water, snacks, ciggys from the street stall downstairs to support real locals  <br />- visit downstairs on shek kip mei street and experience the unique Hong Kong Alfresco dining with exotic seafood (D')
,(733192, 'https://www.airbnb.com/rooms/733192', 'Rental unit in Mong Kok · ★4.64 · 2 bedrooms · 3 beds · 1 bath', 1577.0, 3.0, '["TV", "Smart lock", "Long term stays allowed", "Essentials", "Self check-in", "Hair dryer", "Elevator", "Gym", "Air conditioning", "Iron", "Hangers", "Kitchen", "Cooking basics", "Pets allowed", "Shampoo", "Washer", "Heating", "Hot water", "Wifi"]', 't', '["email", "phone"]', 95, 0, 114.16919, 22.32135, 'Being on the 12/f very quiet and serene, despite being on the main road, it faces the mountains and is very well ventilated.<br /><br />*1 min to Mong Kok MTR and 4 minutes walk to Prince Edward MTR (very close) center of the MTR Map. <br /><br />Central to everything, with all forms of transport available within short walking distance, most notably cabs right outside the entrance, buses (A21 airport bus) Supermarket and Mong Kok MTR across the street, and KCR (trains to new territories + Shenzhen) walking distance<br /><br /><b>The space</b><br />Above average living space fit for western Standards inside yet you''ll surrounded by all the convenience and true Hong Kong vibes and sensual overload with an interesting neighborhood to explore, and one of the easiest if not easiest locations to explore from. <br /><br /> Inside: Fiber optic WiFi of 1000mb/sec (from router) has been installed With LAN cable to the modem this is the fastest WiFi ISP in HK. <br /><br />This apartment is quiet ')
,(849316, 'https://www.airbnb.com/rooms/849316', 'Rental unit in Causeway Bay · ★4.50 · 1 bedroom · 1 bed · 1 bath', 800.0, 1.0, '["Microwave", "Hair dryer", "Carbon monoxide alarm", "Window guards", "Refrigerator", "Bed linens", "Dishes and silverware", "Hangers", "Shampoo", "Children\u2019s dinnerware", "Wifi", "Outlet covers", "Stove", "Keypad", "Extra pillows and blankets", "Washer", "Heating", "Hot water", "Essentials", "Coffee maker", "Free parking on premises", "Kitchen", "Pets allowed", "Dedicated workspace", "Smoke alarm", "Fire extinguisher", "Cleaning products", "Window AC unit", "Paid parking off premises", "Children\u2019s books and toys", "Luggage dropoff allowed", "Iron", "Cooking basics", "Room-darkening shades", "Self check-in", "TV with standard cable"]', 't', '["email", "phone", "work_email"]', 100, 1, 114.18156, 22.27742, 'Full apartment, VERY convenient, Full facilities.  There is a queen bed in the bedroom that sleeps two.  There is a long couch in the living room that can be used as a bed for one person<br /><br />I have two friendly cats.  If you stay at my place you must take care of them.  See notes below.<br /><br /><b>The space</b><br />3 rooms in Causeway Bay - 1 block from Times Square, in the heart of shopping, eating and entertainment for Hong Kong.  1 block from MRT, 5 minutes to trolley, buses to everywhere in Hong Kong.  Wi-Fi, frig, hot plate, microwave, washer dryer. Bathroom with large shower.  <br /><br />4th floor walkup, no doorman, no elevator.  You will need to walk up four flights of stairs to get to the apartment.  Good exercise but to be avoided if you have very heavy luggage!<br /><br />Hundreds of restaurants nearby (I''m not exaggerating), several bars, restaurants, coffee shops on my street.  Grocery store at Leighton Center, at the end of my block.<br /><br /><b>Guest access')
,(860891, 'https://www.airbnb.com/rooms/860891', 'Rental unit in Sai Wan · 2 bedrooms · 2 beds · 1 bath', 1174.0, 2.0, '["TV", "Essentials", "Hair dryer", "Ethernet connection", "Refrigerator", "Air conditioning", "Elevator", "Hot tub", "Bed linens", "Iron", "Hangers", "Kitchen", "Cooking basics", "Dishes and silverware", "Pets allowed", "Washer", "Hot water", "Wifi"]', 't', '["email", "phone"]', 1, 0, 114.14237, 22.28483, '<b>The space</b><br />-2 BEDROOMS (2 BEDROOMS, 2 LIVING ROOMS), 1 SHOWER ROOM.<br />-MIDLEVEL WEST (NEAR THE CENTRE STREET ESCALATOR)<br />-A LOT OF RESTAURANT, COFFEE SHOP, SUPERMARKET.<br />-MTR: SAI YING PUN STATION - 3-5 MINUTES WALK.<br />-CENTRAL MTR STATION TO SAI YING PUN STATION: 3 MINS<br />-15-20 MINS WALK TO MID-LEVEL ESCATOR <br />-3 MINS WALK TO STUBUCK COFFEE SHOP<br />-5 MINS WALK TO SUPERMARKET, MCDONALD<br />-8 MINS WALK TO WET MARKET<br />-10 MINS WALK TO FAMOUS DRY SEAFOOD STREET <br />-WIFI INTERNET & WEEKLY CLEANING SERVICE PROVIDED')
,(881913, 'https://www.airbnb.com/rooms/881913', 'Condo in Sheung Wan · 1 bedroom · 1 bed · 1 bath', 1158.0, 1.0, '["TV", "Barbecue utensils", "Hair dryer", "Refrigerator", "Elevator", "Bed linens", "Dishes and silverware", "Hangers", "Dining table", "Shampoo", "Baking sheet", "Private backyard \u2013 Fully fenced", "Smoking allowed", "Wifi", "Coffee", "Freezer", "Conditioner", "Heating - split type ductless system", "Clothing storage: wardrobe", "Mini fridge", "Extra pillows and blankets", "Oven", "Washer", "Hot water", "Outdoor dining area", "AC - split type ductless system", "Essentials", "Ethernet connection", "Kitchen", "Dryer \u2013\u00a0In unit", "Body soap", "Private patio or balcony", "Pets allowed", "Dedicated workspace", "Shower gel", "Cleaning products", "Outdoor furniture", "Safe", "Iron", "Drying rack for clothing", "Cooking basics", "Hot water kettle", "Room-darkening shades", "BBQ grill"]', 't', '["email", "phone"]', 1, 0, 114.14602, 22.2851, '<b>The space</b><br />one bedroom apartment with Terrace 440 sf on a quiet pedestrian street about 8 minutes walk Mid-Levels Escalators in Central Hong Kong (Soho Area) and 3 minutes walk to Hollywood Road. All the best bars, restaurants, and shops at your doorstep! Modern, light and airy with all conveniences. Wireless internet and weekly cleaning by professional maid included. Walking distance to Sheung Wan or Central/Hong Kong MTR station.<br /><br />***Neihborhood: In between “Central Mid-Levels, & Sai YingPun"')
,(944283, 'https://www.airbnb.com/rooms/944283', 'Rental unit in Central · ★4.66 · 2 bedrooms · 2 beds · 1 bath', 1152.0, 2.0, '["Clothing storage: wardrobe and dresser", "Microwave", "Hair dryer", "48\" TV with Amazon Prime Video, Apple TV, Netflix, standard cable", "Carbon monoxide alarm", "Refrigerator", "Bed linens", "Dishes and silverware", "Hangers", "Host greets you", "Dining table", "Shampoo", "Children\u2019s dinnerware", "Wifi", "Stove", "Freezer", "Free washer", "Air conditioning", "Extra pillows and blankets", "Heating", "Hot water", "Long term stays allowed", "Essentials", "Security cameras on property", "Kitchen", "Pets allowed", "Dedicated workspace", "Smoke alarm", "Wine glasses", "Shower gel", "Cleaning products", "Iron", "Drying rack for clothing", "Cooking basics", "Room-darkening shades", "Dove body soap"]', 't', '["email", "phone"]', 85, 0, 114.15375, 22.28457, 'Soho, best Location in Central. Hong Kong.<br />2 bedrooms fully furnished Flat with Living room, dinning room.<br /><br /><b>The space</b><br />Location, Location!!<br />2 bedrooms apartment (entire flat not a share) for 3 persons stay Maximum.<br />Live in the heart of Soho.Central.<br />Size about 500 sqf.<br /><br />Clean and Simple Flat (walk up one floor), No elevator in the building.<br />This is a classic residential building built in the 1950''s ( not too many left in Hong Kong) Not suitable for young childrens, not childproof and I  don''t have crib or highchair.<br />Amazing location on Wellington street in Central, a cultural and heritage-rich area surrounded by historic landmarks, Temples, art galleries, designer boutiques and antiques shops. very safe and friendly neighborhood.<br />SOHO, a neighborhood known for an appealing mix of old and new and diversity; you''ll find traditional restaurants and outdoor markets on the same streets as cafes and diverse dining,<br />A few ')
,(1036146, 'https://www.airbnb.com/rooms/1036146', 'Rental unit in Discovery Bay · 3 bedrooms · 3 beds · 2 baths', 1857.0, 3.0, '["Elevator", "Air conditioning", "Kitchen", "Pets allowed", "Washer"]', 't', '["email", "phone"]', 1, 0, 114.02187, 22.29549, 'Apartment with seaview   in a resot styled  residential area  with three bed rooms , also  6 people suitable<br /><br />Easy access to Central, Disney,Airport by Ferry, Bus , MTR from Sunny Bay.<br /><br />9 Discovery Bay Road.<br /><br /><b>The space</b><br />An entire   Apartment in Discovery Bay  with  Seaview and Disney Land View is available to rent.<br />Bright flat with many windows.<br /><br />This flat has three rooms, Living room, two bath rooms,Kitchen and a small balcony.<br /><br />Just 15Min Bus ride from Airport Hong Kong  and  25 Min Ferry Ride from Central Pier Hong Kong.<br />Very clean and bright flat with three rooms can accommodate  6 to 7  Guests.<br />There are two elevators in the Building.<br />This building is fairly new and well managed with clean common entrance.<br /><br />There are three bed rooms, two bath rooms, One fairly large Kitchen, small balcony. good sized Living room for HK''s  homes.<br /><br />It is 1068 Sfeet in size.<br /><br />Master bed room')
,(1060831, 'https://www.airbnb.com/rooms/1060831', 'Home in Islands District · ★4.0 · 3 bedrooms · 4 beds · 2 baths', 3990.0, 4.0, '["Dryer", "TV", "Essentials", "Hair dryer", "Air conditioning", "Private entrance", "Hot tub", "Iron", "Hangers", "Kitchen", "Bathtub", "Pets allowed", "Shampoo", "Room-darkening shades", "Washer", "Heating"]', 't', '["email", "phone"]', 5, 0, 114.01123, 22.29288, 'Discovery Bay is a upper class residential area in resort style. near Disney , Nyong Ping cable, Tung Chong  Outlet  and Central. <br /><br /><br />This Beach Town House has three bed rooms, two bath rooms,Kitchen, Terrace in duplex style.<br /><br /><b>The space</b><br />A Three bed roomTown House at Beach village  in duplex type is available to  book. Two bath rooms, and one  large new open kitchen.<br /><br />This semi House in  the most popular area of Discovery Bay Beach Village is renovated for long period, and try to furnish it minimum as possible, as we do plan to lease this popular town house for long term lease, to expat families.<br /><br /><br />Terrace is   furnished with Terrace furniture.<br /><br /><br />25Min by Ferry Ride from Central Pier of Hong Kong ( Ferry runs 24 Hours ). 15 Min Bus ride from  Hong Kong Airport. 15 Min Bus ride to Disney Land.<br />15 Min Bus ride to Nyoung Ping Big Budda Cable car station.<br />Outlet shopping mall..<br /><br />Great dinning Are')
,(1642196, 'https://www.airbnb.com/rooms/1642196', 'Rental unit in Hong Kong · 3 bedrooms · 3 beds · 2 baths', 6000.0, 3.0, '["Carbon monoxide alarm", "Elevator", "Bed linens", "Hangers", "Shampoo", "Wifi", "Keypad", "Shared hot tub", "Air conditioning", "Conditioner", "Bathtub", "Washer", "Heating", "Hot water", "Dryer", "Essentials", "Shared pool", "Kitchen", "Pets allowed", "Mosquito net", "Dedicated workspace", "Smoke alarm", "Shower gel", "Iron", "Self check-in", "TV with standard cable"]', 't', '["email", "phone"]', 0, 0, 114.21915, 22.28934, '<b>The space</b><br />This apartment is newly renovated apartment in the Harbour View Gardens section of Taikoo Shing neighborhood. It''s an iconic page in Hong Kong that is ideal for families and working public. You can learn more about the neighborhood on its wikipedia site: http://en.wikipedia.org/wiki/Taikoo_Shing <br /> <br />The neighborhood is complete with playgrounds, swimming pools, shopping centers, different kinds of schools, large variety of restaurants, and convenient transportation. The MTR is only a few minutes walking distance. Major highways and bus lines are also conveniently accessible from this apartment. <br /> <br />This apartment is intended for people who have work assignments in Hong Kong that needs to a place from a months to a few years. It is ideal for someone to move here with family.  <br /> <br />I am flexible on the lease term and can go on a month-to-month basis. I currently do not have any furnishings in the place, so I would prefer if you have your ow')
,(1708543, 'https://www.airbnb.com/rooms/1708543', 'Rental unit in Hong Kong · ★4.33 · Studio · 1 bed · 1 bath', 960.0, 1.0, '["TV", "Essentials", "Fire extinguisher", "First aid kit", "Elevator", "Air conditioning", "Hangers", "Kitchen", "Pets allowed", "Shampoo", "Heating", "Wifi"]', 't', '["email", "phone", "work_email"]', 8, 0, 114.15223, 22.28203, 'This large studio in the heart of Soho has everything you need for you stay in Hong Kong. Next to the Central escalator,  it''s only a 5 minutes walk to LKF and all of Hong Kong''s CBD.With convenient access to MTR and major bus and tram lines.<br /><br /><b>The space</b><br />The apartment is a well appointed studio that fits 2 people comfortably, any more people than that and I make no guarantees to your comfort level. There''s a large kitchen with all the basics and a large, modern bathroom (a rarity in Hong Kong.)<br />There''s a lot of storage, a very big closet with enough space for all your clothes and more. Also, the bed lifts up to reveal more storage for your luggage or anything else you want to keep out of the way. <br />But what really makes the apartment special is the neighborhood. SoHo and the neighboring Sheung Wan are thriving communities with an eclectic array of restaurants, coffee shops and boutiques from local owners. And it''s just a few minutes to all the large stores')
,(1774268, 'https://www.airbnb.com/rooms/1774268', 'Bed and breakfast in Hong Kong · 1 bedroom · 3 beds · 1.5 baths', 850.0, 3.0, '["TV", "Microwave", "Hair dryer", "Bed linens", "Dishes and silverware", "Dining table", "Shampoo", "Private backyard \u2013 Fully fenced", "Smoking allowed", "Wifi", "Air conditioning", "Bathtub", "Hot water", "Outdoor dining area", "Essentials", "Private hot tub", "Free parking on premises", "Body soap", "Mosquito net", "Pets allowed", "Dedicated workspace", "Portable heater", "Cleaning products", "Outdoor furniture", "Iron", "Lock on bedroom door", "Cooking basics", "BBQ grill"]', 't', '["email", "phone"]', 1, 0, 114.05844, 22.48134, '本地旅人如果不留宿;就包你好玩好吃的bbq吧<br />歡迎一家大小老幼咸宜與眾同樂!<br />planting space acquaponics for rent <br />pm for details<br />更可以教你小孩子畫畫; 做小手工……<br /><br /><b>The space</b><br />solo traveller, short term bnb,  group gathering requiring  some hosting service re also welcome, flexible pricing, pls feel free to app95892519<br /><br /><b>During your stay</b><br />歡迎app me95892519')
,(1832930, 'https://www.airbnb.com/rooms/1832930', 'Rental unit in NT  · ★4.79 · 1 bedroom · 1 bed · 1 bath', 400.0, 1.0, '["Microwave", "Hair dryer", "Refrigerator", "Elevator", "Bed linens", "Dishes and silverware", "Hangers", "Dining table", "Baking sheet", "Smoking allowed", "Wifi", "Coffee maker: Keurig coffee machine", "Freezer", "Gym", "Air conditioning", "Extra pillows and blankets", "Bathtub", "Oven", "Washer", "Heating", "Hot water", "Dryer", "Paid parking on premises", "Toaster", "Long term stays allowed", "Essentials", "Ethernet connection", "Kitchen", "Pets allowed", "Dedicated workspace", "Pool", "Fire extinguisher", "Iron", "Drying rack for clothing", "Cooking basics", "Hot water kettle", "Room-darkening shades", "TV with standard cable"]', 't', '["email", "phone"]', 14, 0, 114.18193, 22.52314, '<b>The space</b><br />800 sq feet apartment with 3 rooms, furnished, very quite, bright and terrace has  green view. Swimming pool and gym facilities is avalible n club house . Restaurants, super market, convenient stores are near by 2 minutes walk. 15 minutes walk to train station. <br /><br />810 sq feet 3 rooms apartment<br /><br />Sheung Shui Station, ExitA3, then take <br />Bus 270 to Tien Ping direction.2 stops only.<br /><br />15 minuts walk from Sheung Shui station to my place.<br />Airport bus 43A from Airport to Sheung Shui Station.')
,(1887541, 'https://www.airbnb.com/rooms/1887541', 'Rental unit in Hong Kong · 1 bedroom · 1 bed · 1 bath', 1456.0, 1.0, '["TV", "First aid kit", "Carbon monoxide alarm", "Refrigerator", "Smart lock", "Smoking allowed", "Backyard", "Wifi", "Air conditioning", "Washer", "Outdoor dining area", "Patio or balcony", "Outdoor kitchen", "Self check-in", "Private hot tub", "Kitchen", "Pets allowed", "Dedicated workspace", "Smoke alarm", "Exercise equipment", "Outdoor furniture", "BBQ grill"]', 't', '["email", "phone"]', 1, 0, 114.14795159940569, 22.285454373050136, 'Amazing location at the heart of Tai Ping Shan (Time Out''s 7th coolest street in the world). <br /><br />500 sq. ft. INTERIOR: designer furnishings, desk + monitor, two TVs, surround sound, three ACs, rain shower, heated bathroom floor, kitchen / bathroom appliances, air purifier, heater, and more.<br /><br />600 sq. ft. PRIVATE EXTERIOR: gym incl. squat rack, jacuzzi, grill, retractable awnings, washer, dyer, and more.<br /><br />Perfect for couples. Weekly domestic helper (cleaning + cooking) available upon request.')
,(1907254, 'https://www.airbnb.com/rooms/1907254', 'Rental unit in Hong Kong · 2 bedrooms · 2 beds · 1 bath', 1158.0, 2.0, '["Microwave", "Hair dryer", "Refrigerator", "Elevator", "Bed linens", "Dishes and silverware", "Hangers", "Dining table", "Shampoo", "Smoking allowed", "Wifi", "Stove", "40\" HDTV", "Freezer", "Conditioner", "Clothing storage: wardrobe", "Mini fridge", "Extra pillows and blankets", "Washer", "Hot water", "Dryer", "AC - split type ductless system", "Toaster", "Long term stays allowed", "Essentials", "Coffee maker", "Ethernet connection", "Cleaning available during stay", "Kitchen", "Body soap", "Rice maker", "Trash compactor", "Pets allowed", "Dedicated workspace", "Wine glasses", "Shower gel", "Cleaning products", "Luggage dropoff allowed", "Iron", "Drying rack for clothing", "Cooking basics", "Hot water kettle", "Room-darkening shades", "Garden view"]', 't', '["email", "phone"]', 0, 0, 114.14365, 22.28323, '<b>The space</b><br />TWO bedroom apartment from Western Mid-Levels Escalators in Western Mid-Level Hong Kong (2 Bedroom, 2 Living Rooms, 1 Shower Room, Semi Open Kitchen). All the best bars, restaurants, and shops at your doorstep! Modern, light and airy with all conveniences. Wireless internet and weekly cleaning by professional maid included.')
,(1944230, 'https://www.airbnb.com/rooms/1944230', 'Rental unit in Discovery Bay, Lantau Island, · ★4.67 · 3 bedrooms · 3 beds · 2 baths', 1700.0, 3.0, '["Dishwasher", "Microwave", "First aid kit", "Hair dryer", "Carbon monoxide alarm", "Refrigerator", "Elevator", "Dishes and silverware", "Hangers", "Shampoo", "Wifi", "Stove", "Air conditioning", "Oven", "Washer", "Heating", "Hot water", "Dryer", "Lockbox", "Long term stays allowed", "Essentials", "Coffee maker", "Kitchen", "Pets allowed", "Smoke alarm", "Pool", "Fire extinguisher", "Sea view", "Luggage dropoff allowed", "Iron", "Crib", "Cooking basics", "Self check-in", "TV with standard cable"]', 't', '["email", "phone", "work_email"]', 62, 0, 114.02168, 22.29376, 'Modernised bright & breezy full sea view apartment overlooking a hideaway beach.<br />Tranquil surroundings. Views towards Disney & Hong Kong harbour.<br />Free WIFI & multi-channel TV.<br />View photo album for various children bed set designs for bedroom themes.<br /><br /><b>The space</b><br />The flat has been completely rewired with new plumbing and sanitary fittings, new tiling, new wood floors, new picture windows providing panoramic sea and harbour views, and located next to a hidden beach with no roads in sight, and therefore a quiet location with a bright and breezy perspective.<br /><br />The Queen sized bed in main bedroom is about <br />Length: 201 cm <br />Width: 169 cm<br /><br />The Double bed in second bedroom is a hidden bed with a double sofa seater which can also be used to expand the width of the hidden bed to queen size when pulled out.<br />Length: 190 cm <br />Width: 140 - 190 cm<br /><br />The loft bed is about <br />Length: 196 cm <br />Width: 99 cm <br />Heig')
,(494271, 'https://www.airbnb.com/rooms/494271', 'Bungalow in Hong Kong · 1 bedroom · 1 bed · 1 bath', 700.0, 1.0, '["Barbecue utensils", "Books and reading material", "Hair dryer", "Refrigerator", "Bed linens", "Sun loungers", "Dishes and silverware", "Hangers", "River view", "Host greets you", "Dining table", "Shampoo", "Baking sheet", "Smoking allowed", "BBQ grill: charcoal", "Wifi", "Portable fans", "Public or shared beach access", "Freezer", "Clothing storage: closet", "Ocean view", "Conditioner", "Hammock", "Blender", "Extra pillows and blankets", "Oven", "Beach view", "Hot water", "Harbor view", "Outdoor dining area", "Lockbox", "Toaster", "Essentials", "Cleaning available during stay", "Kitchen", "Body soap", "Private patio or balcony", "Single level home", "Dedicated workspace", "Wine glasses", "Shower gel", "Sea view", "Cleaning products", "Window AC unit", "Outdoor furniture", "Luggage dropoff allowed", "Iron", "Mountain view", "Lock on bedroom door", "Cooking basics", "Hot water kettle", "Room-darkening shades", "Self check-in"]', 't', '["phone"]', 0, 0, 114.00395029676515, 22.27184274100326, 'A quiet place for an old soul.<br />Female only.<br /><br /><b>The space</b><br />Clean<br />Quiet<br />Fresh air<br /><br /><b>Guest access</b><br />living room<br />kitchen<br />washroom<br />rooftop<br /><br /><b>Other things to note</b><br />I live here with my two lovely dogs, an old siberian husky girl and a young mongrel boy.')
,(1229848, 'https://www.airbnb.com/rooms/1229848', 'Rental unit in Stanley · ★4.47 · 1 bedroom · 1 bed · 1 bath', 1000.0, 1.0, '["Microwave", "Hair dryer", "Refrigerator", "Bay view", "Bed linens", "Dishes and silverware", "Hangers", "Shampoo", "Wifi", "Stove", "Beach essentials", "Ocean view", "Extra pillows and blankets", "Bathtub", "Beach view", "Heating", "Hot water", "Outdoor dining area", "AC - split type ductless system", "Long term stays allowed", "Essentials", "Patio or balcony", "Coffee maker", "Cleaning available during stay", "Kitchen", "Beach access \u2013 Beachfront", "Sea view", "Window AC unit", "Outdoor furniture", "Paid parking off premises", "Iron", "Mountain view", "Cooking basics", "BBQ grill", "TV with standard cable"]', 't', '["email", "phone"]', 30, 0, 114.21369, 22.21892, 'Month discount.Please enquire<br /><br /><b>The space</b><br />July 3-Aug 31 Summer discount $20k inclusive Unique and very cool open plan surfer style flat on top floor of small older building (no lift). Ecletic decor.Huge furnished BBQ rooftop and ceiling to floor windows with fantastic views to beach and mountains. In a famous tourist village with al fresco beach dining,coffeeshops shopping and hiking, beach swimming right outside door. Easy, fast  and fast transportation to city...20-30 mins..at doorstep. Broadband wireless, two flat screens, fully furnished. Surfboard table kitchen and comfy decor. Suitable for a single or couple w child. Great for visiting family and friends. Great if you like a "vacation" outdoor" area in the middle of one of the worlds''s most vibrant cities. Sorry no pets or smokers. All utilities. Previous renters have loved my place. Great for small BBQ parties and meals under the skies.This is absolutely the "best" small inexpensive flat in the area.  Lot of')
;

Web Server 功能

发布房源

房东在管理端,编辑信息并提交到后台,Web Server 收到请求后在 Warebase 中创建新的记录。

INSERT INTO
    listings(
        id,
        listing_url,
        name,
        price,
        beds,
        amenities,
        has_availability,
        host_verifications,
        number_of_reviews,
        number_of_reviews_l30d,
        longitude,
        latitude,
        description
    )
values
    (
        104626,
        'https://www.airbnb.com/rooms/104626',
        'Rental unit in Hong Kong · ★4.38 · 1 bedroom · 1 bed · 1.5 baths',
        2336.0,
        1.0,
        '["Wifi", "Kitchen", "Air conditioning", "TV with standard cable"]',
        't',
        '[]',
        0,
        0,
        114.1479,
        22.2836,
        'listing description'
    );

修改房源

房源供需紧张,房东在管理端调整已有房源价格,Web Server 收到请求后在 Warebase 中更新房源记录。

UPDATE listings SET price=2000 WHERE id=17891;

psql 输出

test=> UPDATE listings SET price=2000 WHERE id=17891;
UPDATE 1
 
test=> SELECT id, price FROM listings where id=17891;
  id   | price
-------+-------
 17891 |  2000
(1 row)
 

旅客搜索房源

旅客在 APP 中,勾选“空闲房源”、“沙滩景房”过滤条件,点击结果按照价格排序, Web Server 收到请求后在 Warebase 中执行查询请求。

SELECT 
    id, -- 房源 ID
    listing_url, -- 详情页面 URL
    price, -- 返回价格信息
    number_of_reviews, -- 返回评论数,辅助旅客决策
    longitude, -- 返回经纬度,用于前端地图展示
    latitude
FROM listings
WHERE 
    has_availability = 't' -- 筛选条件:只看空闲的房源
    AND amenities ? 'Beach view' -- 筛选条件:沙滩景房
ORDER BY price -- 按照价格排序
;

psql 输出

postgres=> SELECT
    id, -- 房源 ID
    listing_url, -- 详情页面 URL
    price, -- 返回价格信息
    number_of_reviews, -- 返回评论数,辅助客户决策
    longitude, -- 返回经纬度,用于前端地图展示
    latitude
FROM listings
WHERE
    has_availability = 't' -- 筛选条件:只看空闲的房源
    AND amenities ? 'Beach view' -- 筛选条件:沙滩景房
ORDER BY price DESC-- 按照价格排序
;
   id    |             listing_url              | price  | number_of_reviews |     longitude      |     latitude
---------+--------------------------------------+--------+-------------------+--------------------+-------------------
 1229848 | https://www.airbnb.com/rooms/1229848 | 1000.0 |                30 |          114.21369 |          22.21892
  494271 | https://www.airbnb.com/rooms/494271  | 700.0  |                 0 | 114.00395029676515 | 22.27184274100326
(2 rows)