├── README.md └── shop.sql /README.md: -------------------------------------------------------------------------------- 1 | # nodejs-rest-api-shopping 2 | Ecommerce Nodejs Mysql 3 | 4 | #Make IMPORT using git clone https://github.com/olympikesoft/nodejs-rest-api-shopping 5 | 6 | # Import Database MYSQL "shopping.sql" in phpmyAdmin 7 | 8 | # Make node start 9 | 10 | It´s DONE!! 11 | 12 | 13 | ![alt text](https://cdn-images-1.medium.com/max/720/1*rJ4WenkCQHQCR5gJeN3ndQ.png) 14 | 15 | Check tutorials in our MEDIUM PAGE! -> https://medium.com/olympikesoft 16 | 17 | Any question put in "issues" 18 | -------------------------------------------------------------------------------- /shop.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.5.1 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: 127.0.0.1 6 | -- Generation Time: 02-Jul-2017 às 22:45 7 | -- Versão do servidor: 10.1.16-MariaDB 8 | -- PHP Version: 5.6.24 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | 14 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 15 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 16 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 17 | /*!40101 SET NAMES utf8mb4 */; 18 | 19 | -- 20 | -- Database: `shop` 21 | -- 22 | 23 | -- -------------------------------------------------------- 24 | 25 | -- 26 | -- Estrutura da tabela `category` 27 | -- 28 | 29 | CREATE TABLE `category` ( 30 | `id` int(11) NOT NULL, 31 | `name` varchar(45) NOT NULL 32 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 33 | 34 | -- 35 | -- Extraindo dados da tabela `category` 36 | -- 37 | 38 | INSERT INTO `category` (`id`, `name`) VALUES 39 | (1, 'Consolas'), 40 | (2, 'Playstation 3'), 41 | (3, 'Computadores'), 42 | (4, 'Tablets'), 43 | (5, 'Capas Telemóveis'), 44 | (6, 'Telemóveis'), 45 | (7, 'Exclusive'), 46 | (8, 'Relógios'); 47 | 48 | -- -------------------------------------------------------- 49 | 50 | -- 51 | -- Estrutura da tabela `color` 52 | -- 53 | 54 | CREATE TABLE `color` ( 55 | `id` int(11) NOT NULL, 56 | `name` varchar(45) NOT NULL 57 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 58 | 59 | -- 60 | -- Extraindo dados da tabela `color` 61 | -- 62 | 63 | INSERT INTO `color` (`id`, `name`) VALUES 64 | (1, 'Preto'), 65 | (2, 'Branco'); 66 | 67 | -- -------------------------------------------------------- 68 | 69 | -- 70 | -- Estrutura da tabela `image` 71 | -- 72 | 73 | CREATE TABLE `image` ( 74 | `img_id` int(10) UNSIGNED NOT NULL, 75 | `file_name` varchar(45) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, 76 | `product_id` int(11) NOT NULL 77 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 78 | 79 | -- 80 | -- Extraindo dados da tabela `image` 81 | -- 82 | 83 | INSERT INTO `image` (`img_id`, `file_name`, `product_id`) VALUES 84 | (1, 'imagesfile-1498410315679.jpg', 68); 85 | 86 | -- -------------------------------------------------------- 87 | 88 | -- 89 | -- Estrutura da tabela `invoice` 90 | -- 91 | 92 | CREATE TABLE `invoice` ( 93 | `id` int(11) NOT NULL, 94 | `datetime` datetime(6) NOT NULL, 95 | `Payment_id` int(11) NOT NULL, 96 | `Shipment_id` int(11) NOT NULL, 97 | `Orders_id` int(11) NOT NULL 98 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 99 | 100 | -- -------------------------------------------------------- 101 | 102 | -- 103 | -- Estrutura da tabela `orders` 104 | -- 105 | 106 | CREATE TABLE `orders` ( 107 | `id` int(11) NOT NULL, 108 | `User_id` int(11) NOT NULL, 109 | `date_time` datetime(6) NOT NULL, 110 | `quantity` int(11) NOT NULL 111 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 112 | 113 | -- 114 | -- Extraindo dados da tabela `orders` 115 | -- 116 | 117 | INSERT INTO `orders` (`id`, `User_id`, `date_time`, `quantity`) VALUES 118 | (1, 1, '2017-07-01 10:23:25.459000', 0), 119 | (2, 1, '2017-07-01 10:23:25.459000', 1); 120 | 121 | -- -------------------------------------------------------- 122 | 123 | -- 124 | -- Estrutura da tabela `orders_item` 125 | -- 126 | 127 | CREATE TABLE `orders_item` ( 128 | `Orders_id` int(11) NOT NULL, 129 | `Product_id` int(11) NOT NULL, 130 | `id` int(11) NOT NULL, 131 | `quantity` int(11) NOT NULL, 132 | `datetime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP 133 | ) ; 134 | 135 | -- 136 | -- Extraindo dados da tabela `orders_item` 137 | -- 138 | 139 | INSERT INTO `orders_item` (`Orders_id`, `Product_id`, `id`, `quantity`, `datetime`) VALUES 140 | (1, 5, 1, 1, '0000-00-00 00:00:00.000000'), 141 | (1, 67, 7, 1, '2017-07-02 16:23:51.046743'), 142 | (1, 19, 8, 1, '2017-07-02 17:00:04.170430'), 143 | (1, 5, 9, 1, '2017-07-02 17:13:08.377808'); 144 | 145 | -- -------------------------------------------------------- 146 | 147 | -- 148 | -- Estrutura da tabela `payment` 149 | -- 150 | 151 | CREATE TABLE `payment` ( 152 | `id` int(11) NOT NULL, 153 | `datetime` datetime(6) NOT NULL, 154 | `amount` int(11) NOT NULL, 155 | `Orders_id` int(11) NOT NULL, 156 | `User_id` int(11) NOT NULL 157 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 158 | 159 | -- -------------------------------------------------------- 160 | 161 | -- 162 | -- Estrutura da tabela `product` 163 | -- 164 | 165 | CREATE TABLE `product` ( 166 | `id` int(11) NOT NULL, 167 | `name` varchar(45) NOT NULL, 168 | `price` double NOT NULL, 169 | `quantity` int(11) NOT NULL, 170 | `state` int(1) NOT NULL, 171 | `date_inserted` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 172 | `loves` int(11) NOT NULL, 173 | `Category_id` int(11) NOT NULL, 174 | `Color_id` int(11) NOT NULL, 175 | `description` text NOT NULL 176 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 177 | 178 | -- 179 | -- Extraindo dados da tabela `product` 180 | -- 181 | 182 | INSERT INTO `product` (`id`, `name`, `price`, `quantity`, `state`, `date_inserted`, `loves`, `Category_id`, `Color_id`, `description`) VALUES 183 | (5, 'Mac Book Air Core i5 C/ disco SSD 120 GB', 500, 1000, 0, '0000-00-00 00:00:00', 0, 3, 2, 'Vendo Mac Book Air 11 " em perfeito estado de aparência e funcionamento , com capa de protecção '), 184 | (19, 'Portátil HP Pavilion x360 13-u104np', 850, 1000, 0, '0000-00-00 00:00:00', 0, 3, 1, 'Portátil HP Pavilion x360 13-u104np'), 185 | (67, 'Relógio estilo TOUS em Bronze', 20, 100, 1, '2017-07-01 12:38:55', 0, 8, 1, 'Relógio para Senhora / Mulher Feminino estilo TOUS em Bronze\r\n'), 186 | (68, 'Toshiba Qosmio F60-124 ', 600, 100, 0, '0000-00-00 00:00:00', 0, 3, 1, 'Processador: Processador Intel Core i7-740QM (1.73GHz)\r\nCache: 6MB\r\nMemória: 8GB de memória DDR3 (4GB 4GB)\r\nDisco Rigido: 640GB\r\nPlaca Gráfica: NVIDIA ® GeForce GT 330M\r\nMemória da Placa Gráfica: 1GB\r\nMonitor: 15,6 polegadas (1366 x 768)\r\nSistema de Áudio: Formato de áudio suportado: Estéreo de 24 bits \r\nColunas: Estéreo Harman Kardon ® \r\nFabricante: Sistema Som Toshiba Bass Enhanced\r\nInterfaces: 1 x Entrada DC \r\n1 x monitor Externo \r\n1 x RJ-45 \r\n1 x Microfone Externo \r\n1 x auriculares (Estéreo) \r\n1 x HDMI-CEC (REGZA-Link) com Suporte 1080p Formato de Sinal \r\n1 x Câmara Web Integrada HD (1280 x 800) com Suporte Integrado AutoMacro microfone e \r\n3 (1 Lado Esquerdo, 2 Lado Direito) x USB 2.0 \r\n1 (Esquerda) x eSATA / USB Suporte com 2,0 USB Sleep-and-Charge \r\n1 x Leitor Multi-Card (suporta cartões SDT comeu 16 GB, Memory Stick ® comeu 256 MB, Memory Stick ProT comeu 2 GB, MultiMedia CardT comeu 2 GB e xD-Picture CardT comeu 2 GB)\r\nComunicações: Compatibilidade: Wi-Fi ® \r\nSuporte de Rede: 802.11b/g/n \r\nFiOS SEM Tecnologia: Wireless LAN \r\nFiOS SEM Tecnologia: Bluetooth ®\r\nSistema Operativo: Windows ® Home Premium Genuíno 7 de 64 bits\r\nExpansibilidade: 2 x 2 slots de Memória\r\nSoftware: Toshiba BluetoothT Stack \r\nToshiba BluetoothT Monitor \r\nToshiba Disc Creator \r\nManual de Utilizador Toshiba \r\nToshiba Assist \r\nAssistente Câmera Chicony Software \r\nToshiba DVD Player \r\nRECONHECIMENTO facial da Toshiba \r\nControlo de Gestão HDMI \r\nMicrosoft ® Works, Microsoft ® Office Home e Student 2007 (versão Demonstração gratuita de 60 Dias) \r\nToshiba Value Added Package (Toshiba Power Saver, Toshiba Zoom Utility, ferramenta de diagnóstico do PC Toshiba, a Toshiba Flash Cards, Toshiba Driver componentes comuns Acessibilidade Toshiba, Suporte Botões Toshiba) \r\nMcAfee ® Internet Security (Incluí actualização de Internet Gratis Por 30 Dias) \r\nConsola Jogos WildTangent \r\nToshiba Serviço de Imagem \r\nRecuperação Toshiba Media Creator \r\nWinDVD ® BD parágrafo Toshiba \r\nCorel ® DVD MovieFactory ® parágrafo Toshiba \r\nConnectivity Doctor \r\nConfigFreeT \r\ne Utilitarios drivers Toshiba \r\nGoogle Toolbar\r\nDimensões: 388 x 267 x 29 mm\r\nPeso: 2,8 kg'); 187 | 188 | -- -------------------------------------------------------- 189 | 190 | -- 191 | -- Estrutura da tabela `shipment` 192 | -- 193 | 194 | CREATE TABLE `shipment` ( 195 | `id` int(11) NOT NULL, 196 | `shipment_date` date NOT NULL, 197 | `Orders_id` int(11) NOT NULL 198 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 199 | 200 | -- -------------------------------------------------------- 201 | 202 | -- 203 | -- Estrutura da tabela `size` 204 | -- 205 | 206 | CREATE TABLE `size` ( 207 | `id` int(11) NOT NULL, 208 | `name` varchar(90) NOT NULL 209 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 210 | 211 | -- 212 | -- Extraindo dados da tabela `size` 213 | -- 214 | 215 | INSERT INTO `size` (`id`, `name`) VALUES 216 | (1, 'S'), 217 | (2, 'XS'), 218 | (3, 'M'), 219 | (4, 'L'); 220 | 221 | -- -------------------------------------------------------- 222 | 223 | -- 224 | -- Estrutura da tabela `user` 225 | -- 226 | 227 | CREATE TABLE `user` ( 228 | `id` int(11) NOT NULL, 229 | `name` varchar(90) NOT NULL, 230 | `email` varchar(45) NOT NULL, 231 | `password` varchar(90) NOT NULL, 232 | `telefone` int(11) NOT NULL, 233 | `state` int(1) DEFAULT '1', 234 | `morada` varchar(90) NOT NULL, 235 | `last_login` datetime(6) DEFAULT CURRENT_TIMESTAMP 236 | ) ; 237 | 238 | -- 239 | -- Extraindo dados da tabela `user` 240 | -- 241 | 242 | INSERT INTO `user` (`id`, `name`, `email`, `password`, `telefone`, `state`, `morada`, `last_login`, `sobrename`) VALUES 243 | (1, 'admin', 'tester@gmail.com', 'antonio10', 962796473, 1, 'Travessa dos Ferreiras n~30 Santo Antonio10', '2017-07-01 09:20:20.334334', 'Rodrigues'); 244 | 245 | -- -------------------------------------------------------- 246 | 247 | -- 248 | -- Estrutura da tabela `whislist` 249 | -- 250 | 251 | CREATE TABLE `whislist` ( 252 | `id` int(11) NOT NULL, 253 | `datetime` datetime(6) NOT NULL, 254 | `User_id` int(11) NOT NULL, 255 | `Product_id` int(11) NOT NULL 256 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 257 | 258 | -- 259 | -- Indexes for dumped tables 260 | -- 261 | 262 | -- 263 | -- Indexes for table `category` 264 | -- 265 | ALTER TABLE `category` 266 | ADD PRIMARY KEY (`id`); 267 | 268 | -- 269 | -- Indexes for table `color` 270 | -- 271 | ALTER TABLE `color` 272 | ADD PRIMARY KEY (`id`); 273 | 274 | -- 275 | -- Indexes for table `image` 276 | -- 277 | ALTER TABLE `image` 278 | ADD PRIMARY KEY (`img_id`), 279 | ADD KEY `product_id` (`product_id`); 280 | 281 | -- 282 | -- Indexes for table `invoice` 283 | -- 284 | ALTER TABLE `invoice` 285 | ADD PRIMARY KEY (`id`), 286 | ADD KEY `fk_Invoice_Payment1_idx` (`Payment_id`), 287 | ADD KEY `fk_Invoice_Shipment1_idx` (`Shipment_id`), 288 | ADD KEY `fk_Invoice_Orders1_idx` (`Orders_id`); 289 | 290 | -- 291 | -- Indexes for table `orders` 292 | -- 293 | ALTER TABLE `orders` 294 | ADD PRIMARY KEY (`id`), 295 | ADD KEY `fk_Orders_Product_User1_idx` (`User_id`); 296 | 297 | -- 298 | -- Indexes for table `payment` 299 | -- 300 | ALTER TABLE `payment` 301 | ADD PRIMARY KEY (`id`), 302 | ADD KEY `fk_Payment_Orders1_idx` (`Orders_id`), 303 | ADD KEY `fk_Payment_User1_idx` (`User_id`); 304 | 305 | -- 306 | -- Indexes for table `product` 307 | -- 308 | ALTER TABLE `product` 309 | ADD PRIMARY KEY (`id`), 310 | ADD KEY `fk_Product_Category1_idx` (`Category_id`), 311 | ADD KEY `fk_Product_Color1_idx` (`Color_id`); 312 | 313 | -- 314 | -- Indexes for table `shipment` 315 | -- 316 | ALTER TABLE `shipment` 317 | ADD PRIMARY KEY (`id`), 318 | ADD KEY `fk_Shipment_Orders1_idx` (`Orders_id`); 319 | 320 | -- 321 | -- Indexes for table `size` 322 | -- 323 | ALTER TABLE `size` 324 | ADD PRIMARY KEY (`id`); 325 | 326 | -- 327 | -- Indexes for table `whislist` 328 | -- 329 | ALTER TABLE `whislist` 330 | ADD PRIMARY KEY (`id`), 331 | ADD KEY `fk_Whislist_User1_idx` (`User_id`), 332 | ADD KEY `fk_Whislist_Product1_idx` (`Product_id`); 333 | 334 | -- 335 | -- AUTO_INCREMENT for dumped tables 336 | -- 337 | 338 | -- 339 | -- AUTO_INCREMENT for table `category` 340 | -- 341 | ALTER TABLE `category` 342 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; 343 | -- 344 | -- AUTO_INCREMENT for table `image` 345 | -- 346 | ALTER TABLE `image` 347 | MODIFY `img_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; 348 | -- 349 | -- AUTO_INCREMENT for table `orders` 350 | -- 351 | ALTER TABLE `orders` 352 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; 353 | -- 354 | -- AUTO_INCREMENT for table `orders_item` 355 | -- 356 | ALTER TABLE `orders_item` 357 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 358 | -- 359 | -- AUTO_INCREMENT for table `payment` 360 | -- 361 | ALTER TABLE `payment` 362 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 363 | -- 364 | -- AUTO_INCREMENT for table `product` 365 | -- 366 | ALTER TABLE `product` 367 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=69; 368 | -- 369 | -- AUTO_INCREMENT for table `shipment` 370 | -- 371 | ALTER TABLE `shipment` 372 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 373 | -- 374 | -- AUTO_INCREMENT for table `user` 375 | -- 376 | ALTER TABLE `user` 377 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 378 | -- 379 | -- AUTO_INCREMENT for table `whislist` 380 | -- 381 | ALTER TABLE `whislist` 382 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 383 | -- 384 | -- Constraints for dumped tables 385 | -- 386 | 387 | -- 388 | -- Limitadores para a tabela `image` 389 | -- 390 | ALTER TABLE `image` 391 | ADD CONSTRAINT `fk_shop_product` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; 392 | 393 | -- 394 | -- Limitadores para a tabela `invoice` 395 | -- 396 | ALTER TABLE `invoice` 397 | ADD CONSTRAINT `fk_Invoice_Orders1` FOREIGN KEY (`Orders_id`) REFERENCES `orders` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, 398 | ADD CONSTRAINT `fk_Invoice_Payment1` FOREIGN KEY (`Payment_id`) REFERENCES `payment` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, 399 | ADD CONSTRAINT `fk_Invoice_Shipment1` FOREIGN KEY (`Shipment_id`) REFERENCES `shipment` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; 400 | 401 | -- 402 | -- Limitadores para a tabela `orders` 403 | -- 404 | ALTER TABLE `orders` 405 | ADD CONSTRAINT `fk_Orders_Product_User1` FOREIGN KEY (`User_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; 406 | 407 | -- 408 | -- Limitadores para a tabela `payment` 409 | -- 410 | ALTER TABLE `payment` 411 | ADD CONSTRAINT `fk_Payment_Orders1` FOREIGN KEY (`Orders_id`) REFERENCES `orders` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, 412 | ADD CONSTRAINT `fk_Payment_User1` FOREIGN KEY (`User_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; 413 | 414 | -- 415 | -- Limitadores para a tabela `product` 416 | -- 417 | ALTER TABLE `product` 418 | ADD CONSTRAINT `fk_Product_Category1` FOREIGN KEY (`Category_id`) REFERENCES `category` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, 419 | ADD CONSTRAINT `fk_Product_Color1` FOREIGN KEY (`Color_id`) REFERENCES `color` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; 420 | 421 | -- 422 | -- Limitadores para a tabela `shipment` 423 | -- 424 | ALTER TABLE `shipment` 425 | ADD CONSTRAINT `fk_Shipment_Orders1` FOREIGN KEY (`Orders_id`) REFERENCES `orders` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; 426 | 427 | -- 428 | -- Limitadores para a tabela `whislist` 429 | -- 430 | ALTER TABLE `whislist` 431 | ADD CONSTRAINT `fk_Whislist_Product1` FOREIGN KEY (`Product_id`) REFERENCES `product` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, 432 | ADD CONSTRAINT `fk_Whislist_User1` FOREIGN KEY (`User_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION; 433 | 434 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 435 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 436 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 437 | --------------------------------------------------------------------------------