Best JavaScript code snippet using unexpected
seed.js
Source:seed.js
1/**2 * Populate DB with sample data on server start3 * to disable, edit config/environment/index.js, and set `seedDB: false`4 */5'use strict';6var _ = require('lodash');7var Thing = require('../api/thing/thing.model');8var User = require('../api/user/user.model');9var Company = require('../api/company/company.model');10var Building = require('../api/building/building.model');11var Unit = require('../api/unit/unit.model');12var Customer = require('../api/customer/customer.model');13var Contract = require('../api/contract/contract.model');14var Invoice = require('../api/invoice/invoice.model');15var ExchangeRate = require('../api/exchange_rate/exchange_rate.model');16Thing.find({}).remove(function() {17 Thing.create({18 name : 'Development Tools',19 info : 'Integration with popular tools such as Bower, Grunt, Karma, Mocha, JSHint, Node Inspector, Livereload, Protractor, Jade, Stylus, Sass, CoffeeScript, and Less.'20 }, {21 name : 'Server and Client integration',22 info : 'Built with a powerful and fun stack: MongoDB, Express, AngularJS, and Node.'23 }, {24 name : 'Smart Build System',25 info : 'Build system ignores `spec` files, allowing you to keep tests alongside code. Automatic injection of scripts and styles into your index.html'26 }, {27 name : 'Modular Structure',28 info : 'Best practice client and server structures allow for more code reusability and maximum scalability'29 }, {30 name : 'Optimized Build',31 info : 'Build process packs up your templates as a single JavaScript payload, minifies your scripts/css/images, and rewrites asset names for caching.'32 }, {33 name : 'Deployment Ready',34 info : 'Easily deploy your app to Heroku or Openshift with the heroku and openshift subgenerators'35 });36});37// User.find({}).remove(function() {38// User.create({39// provider: 'local',40// name: 'Test User',41// email: 'test@test.com',42// password: 'test'43// }, {44// provider: 'local',45// role: 'admin',46// name: 'Admin',47// email: 'admin@admin.com',48// password: 'admin'49// }, function(err, data) {50// user = data;51// console.log('finished populating users'+ user);52// }53// );54// });55User.find({}).remove().exec()56 .then(function() {57 return User.create({58 provider: 'local',59 name: 'Test User',60 email: 'test@test.com',61 password: 'test'62 }, function(err, user) {63 return;64 });65 })66 .then(function() {67 return User.create({68 provider: 'local',69 role: 'admin',70 name: 'Admin',71 email: 'admin@admin.com',72 password: 'admin'73 }, function(err, user) {74 return;75 });76 })77 .then(function (user) {78 return Company.find({}).remove().exec()79 .then(function () {80 return user;81 });82 })83 .then(function (user) {84 return Company.create({85 name: 'Inmobiliaria Celu',86 })87 .then(function (company) {88 return {89 user: user,90 company: company91 }92 });93 })94 .then(function (result) {95 result.company.users.push(result.user);96 return result;97 })98 .then(function (result) {99 return Building.find({}).remove().exec()100 .then(function () {101 return result;102 });103 })104 .then(function (result) {105 return Building.create({106 name: 'Centro de Negocios Akbal',107 company: result.company108 })109 .then(function (building) {110 result.buildings = [building];111 return result;112 });113 })114 .then(function (result) {115 return Building.create({116 name: 'Rivera Lara',117 company: result.company118 })119 .then(function (building) {120 result.buildings.push(building);121 return result;122 });123 })124 .then(function (result) {125 return Building.create({126 name: 'Plaza Micaela',127 company: result.company128 })129 .then(function (building) {130 result.buildings.push(building);131 return result;132 });133 })134 .then(function (result) {135 return Building.create({136 name: 'Centro Ejecutivo Celu',137 company: result.company138 })139 .then(function (building) {140 result.buildings.push(building);141 return result;142 });143 })144 .then(function (result) {145 return Building.create({146 name: 'Archivo Seguro',147 company: result.company148 })149 .then(function (building) {150 result.buildings.push(building);151 return result;152 });153 })154 .then(function (result) {155 return Invoice.find({}).remove().exec()156 .then(function () {157 return result;158 });159 })160 .then(function (result) {161 return Invoice.create({162 serie: 'A',163 folio: '1',164 amount: 10000,165 tax: 1600,166 total: 11600,167 seal_date: new Date(),168 cancel_date: new Date(),169 company: result.company170 })171 .then(function (invoice) {172 result.invoices = [invoice];173 return result;174 });175 })176 .then(function (result) {177 var company = result.company;178 var buildings = result.buildings;179 var invoices = result.invoices;180 buildings.forEach(function (building) {181 company.buildings.push(building);182 })183 invoices.forEach(function (invoice) {184 company.invoices.push(invoice);185 })186 return Company.findById(company._id).exec()187 .then(function (data) {188 var updated = _.merge(data, company);189 result.updated = updated;190 return result;191 });192 })193 .then(function (result) {194 var updated = result.updated;195 return updated.save().then(function () {196 result.company = updated;197 return result;198 });199 })200 .then(function (result) {201 return Unit.find({}).remove().exec()202 .then(function () {203 return result;204 });205 })206 .then(function (result) {207 return Customer.find({}).remove().exec()208 .then(function () {209 return result;210 });211 })212 .then(function (result) {213 return Contract.find({}).remove().exec()214 .then(function () {215 return result;216 });217 })218 .then(function (result) {219 return Unit.create({220 local: 1,221 surface: 501,222 type: 'Bodega',223 description: '',224 ocupated: false,225 building: result.buildings[0]226 })227 .then(function (unit) {228 result.units = [[unit]];229 return result;230 });231 })232 .then(function (result) {233 return Unit.create({234 local: 2,235 surface: 501,236 type: 'Bodega',237 description: '',238 ocupated: false,239 building: result.buildings[0]240 })241 .then(function (unit) {242 result.units[0].push(unit);243 return result;244 });245 })246 .then(function (result) {247 return Unit.create({248 local: 3,249 surface: 551,250 type: 'Bodega',251 description: '',252 ocupated: false,253 building: result.buildings[0]254 })255 .then(function (unit) {256 result.units[0].push(unit);257 return result;258 });259 })260 .then(function (result) {261 return Unit.create({262 local: 4,263 surface: 551,264 type: 'Bodega',265 description: '',266 ocupated: false,267 building: result.buildings[0]268 })269 .then(function (unit) {270 result.units[0].push(unit);271 return result;272 });273 })274 .then(function (result) {275 return Unit.create({276 local: 5,277 surface: 451,278 type: 'Bodega',279 description: '',280 ocupated: false,281 building: result.buildings[0]282 })283 .then(function (unit) {284 result.units[0].push(unit);285 return result;286 });287 })288 .then(function (result) {289 return Unit.create({290 local: 10,291 surface: 100,292 type: 'Comercial',293 description: 'Local Alimentos',294 ocupated: false,295 building: result.buildings[0]296 })297 .then(function (unit) {298 result.units[0].push(unit);299 return result;300 });301 })302 .then(function (result) {303 return Customer.create({304 name: 'ARTESANIAS PASO DEL NORTE, S.A. DE C.V.',305 tradename: 'ARTESANIAS PASO DEL NORTE, S.A. DE C.V.',306 rfc: 'APN120320PD2',307 address: 'Ave. Hermanos Escobar No. 6026-5',308 neiborhood: 'Col. Partido Romero',309 zipCode: '32320',310 city: 'Juarez',311 state: 'Chihuahua',312 country: 'Mexico',313 representative: 'Oscar Nuñez',314 email: 'aletorres_apn@yahoo.com',315 currency: 'dolares',316 building: result.buildings[0]317 })318 .then(function (customer) {319 result.customers = [[customer]];320 return result;321 });322 })323 .then(function (result) {324 return Customer.create({325 name: 'INGENIERIA Y DISEÃO AVANZADO, S. DE R.L. DE C.V.',326 tradename: 'INGENIERIA Y DISEÃO AVANZADO, S. DE R.L. DE C.V.',327 rfc: 'IDA110819SD7',328 address: 'Privada de los Gitanos No. 11631',329 neiborhood: 'Ortiz Rubio',330 zipCode: '32548',331 city: 'Juarez',332 state: 'Chihuahua',333 country: 'Mexico',334 representative: 'Paulina Ciria Merchan',335 email: 'fmiranda@akbalsc.com',336 currency: 'dolares',337 building: result.buildings[0]338 })339 .then(function (customer) {340 result.customers[0].push(customer);341 return result;342 });343 })344 .then(function (result) {345 return Customer.create({346 name: 'ARROW COMPONENTS MEXICO, S.A. DE C.V.',347 tradename: 'ARROW COMPONENTS MEXICO, S.A. DE C.V.',348 rfc: 'ACM841025CA5',349 address: 'Ejercito Nacional No. 216-8',350 neiborhood: 'Delegacion Miguel Hidalgo',351 zipCode: '11590',352 city: 'Mexico D.F.',353 state: 'D.F.',354 country: 'Mexico',355 representative: 'Ana Maria Elena Bedia Sanchez',356 email: 'fmiranda@akbalsc.com',357 currency: 'dolares',358 building: result.buildings[0]359 })360 .then(function (customer) {361 result.customers[0].push(customer);362 return result;363 });364 })365 .then(function (result) {366 return Customer.create({367 name: 'INTEGRATED LOGISTICS SYSTEMS, S.R.L. DE C.V.',368 tradename: 'INTEGRATED LOGISTICS SYSTEMS, S.R.L. DE C.V.',369 rfc: 'ILS9810063P8',370 address: 'Metalurgia No. 1513',371 neiborhood: 'Partido Escobedo',372 zipCode: '45000',373 city: 'Tlaquepaque',374 state: 'Jalisco',375 country: 'Mexico',376 representative: 'Alejandra Gomez Lomeli',377 email: 'fmiranda@akbalsc.com',378 currency: 'dolares',379 building: result.buildings[0]380 })381 .then(function (customer) {382 result.customers[0].push(customer);383 return result;384 });385 })386 .then(function (result) {387 return Contract.create({388 startDate: new Date(2012,8,1),389 endDate: new Date(2015,7,31),390 monthlyRent: '2064.12',391 taxRate: 16,392 currency: 'dolares',393 paymentMethod: 'Transferencia Electronica',394 deposit: '',395 maintenanceFee: '250.5',396 taxOverdue: '',397 marginsDay: 10,398 building: result.buildings[0],399 unit: result.units[0][0],400 customer: result.customers[0][0],401 })402 .then(function (contract) {403 result.contracts = [[contract]];404 result.units[0][0].contracts.push(contract);405 result.customers[0][0].contracts.push(contract);406 return result;407 });408 })409 .then(function (result) {410 var unit = result.units[0][0];411 return Unit.findById(unit._id).exec()412 .then(function (data) {413 var updated = _.merge(data, unit);414 result.updated = updated;415 return result;416 });417 })418 .then(function (result) {419 var updated = result.updated;420 return updated.save().then(function () {421 result.units[0][0] = updated;422 return result;423 });424 })425 // .then(function (result) {426 // var customer = result.customers[0][0];427 // return Customer.findById(customer._id).exec()428 // .then(function (data) {429 // var updated = _.merge(data, customer);430 // result.updated = updated;431 // return result;432 // });433 // })434 // .then(function (result) {435 // var updated = result.updated;436 // return updated.save().then(function () {437 // result.customers[0][0] = updated;438 // return result;439 // });440 // })441 .then(function (result) {442 return Contract.create({443 startDate: new Date(2012,8,1),444 endDate: new Date(2015,7,31),445 monthlyRent: '1653.3',446 taxRate: 16,447 currency: 'dolares',448 paymentMethod: 'Transferencia Electronica',449 deposit: '',450 maintenanceFee: '250.5',451 taxOverdue: '',452 marginsDay: 10,453 building: result.buildings[0],454 unit: result.units[0][1],455 customer: result.customers[0][1],456 })457 .then(function (contract) {458 result.contracts[0].push(contract);459 result.units[0][1].contracts.push(contract);460 result.customers[0][1].contracts.push(contract);461 return result;462 });463 })464 .then(function (result) {465 var unit = result.units[0][1];466 return Unit.findById(unit._id).exec()467 .then(function (data) {468 var updated = _.merge(data, unit);469 result.updated = updated;470 return result;471 });472 })473 .then(function (result) {474 var updated = result.updated;475 return updated.save().then(function () {476 result.units[0][1] = updated;477 return result;478 });479 })480 .then(function (result) {481 var customer = result.customers[0][1];482 return Customer.findById(customer._id).exec()483 .then(function (data) {484 var updated = _.merge(data, customer);485 result.updated = updated;486 return result;487 });488 })489 .then(function (result) {490 var updated = result.updated;491 return updated.save().then(function () {492 result.customers[0][1] = updated;493 return result;494 });495 })496 .then(function (result) {497 return Contract.create({498 startDate: new Date(2014,4,1),499 endDate: new Date(2017,3,30),500 monthlyRent: '3002.95',501 taxRate: 16,502 currency: 'dolares',503 paymentMethod: 'Transferencia Electronica',504 deposit: '',505 maintenanceFee: '275.5',506 taxOverdue: '',507 marginsDay: 10,508 building: result.buildings[0],509 unit: result.units[0][2],510 customer: result.customers[0][2],511 })512 .then(function (contract) {513 result.contracts[0].push(contract);514 result.units[0][2].contracts.push(contract);515 result.customers[0][2].contracts.push(contract);516 return result;517 });518 })519 .then(function (result) {520 var unit = result.units[0][2];521 return Unit.findById(unit._id).exec()522 .then(function (data) {523 var updated = _.merge(data, unit);524 result.updated = updated;525 return result;526 });527 })528 .then(function (result) {529 var updated = result.updated;530 return updated.save().then(function () {531 result.units[0][2] = updated;532 return result;533 });534 })535 .then(function (result) {536 var customer = result.customers[0][2];537 return Customer.findById(customer._id).exec()538 .then(function (data) {539 var updated = _.merge(data, customer);540 result.updated = updated;541 return result;542 });543 })544 .then(function (result) {545 var updated = result.updated;546 return updated.save().then(function () {547 result.customers[0][2] = updated;548 return result;549 });550 })551 .then(function (result) {552 return Contract.create({553 startDate: new Date(2013,8,1),554 endDate: new Date(2016,7,31),555 monthlyRent: '2286.65',556 taxRate: 16,557 currency: 'dolares',558 paymentMethod: 'Transferencia Electronica',559 deposit: '',560 maintenanceFee: '275.5',561 taxOverdue: '',562 marginsDay: 10,563 building: result.buildings[0],564 unit: result.units[0][3],565 customer: result.customers[0][3],566 })567 .then(function (contract) {568 result.contracts[0].push(contract);569 result.units[0][3].contracts.push(contract);570 result.customers[0][3].contracts.push(contract);571 return result;572 });573 })574 .then(function (result) {575 var unit = result.units[0][3];576 return Unit.findById(unit._id).exec()577 .then(function (data) {578 var updated = _.merge(data, unit);579 result.updated = updated;580 return result;581 });582 })583 .then(function (result) {584 var updated = result.updated;585 return updated.save().then(function () {586 result.units[0][3] = updated;587 return result;588 });589 })590 .then(function (result) {591 var customer = result.customers[0][3];592 return Customer.findById(customer._id).exec()593 .then(function (data) {594 var updated = _.merge(data, customer);595 result.updated = updated;596 return result;597 });598 })599 .then(function (result) {600 var updated = result.updated;601 return updated.save().then(function () {602 result.customers[0][3] = updated;603 return result;604 });605 })606 .then(function (result) {607 return Contract.create({608 startDate: new Date(2013,2,15),609 endDate: new Date(2016,2,14),610 monthlyRent: '1858.12',611 taxRate: 16,612 currency: 'dolares',613 paymentMethod: 'Transferencia Electronica',614 deposit: '',615 maintenanceFee: '225.5',616 taxOverdue: '',617 marginsDay: 10,618 building: result.buildings[0],619 unit: result.units[0][4],620 customer: result.customers[0][0],621 })622 .then(function (contract) {623 result.contracts[0].push(contract);624 result.units[0][4].contracts.push(contract);625 result.customers[0][0].contracts.push(contract);626 return result;627 });628 })629 .then(function (result) {630 var unit = result.units[0][4];631 return Unit.findById(unit._id).exec()632 .then(function (data) {633 var updated = _.merge(data, unit);634 result.updated = updated;635 return result;636 });637 })638 .then(function (result) {639 var updated = result.updated;640 return updated.save().then(function () {641 result.units[0][4] = updated;642 return result;643 });644 })645 .then(function (result) {646 var customer = result.customers[0][0];647 return Customer.findById(customer._id).exec()648 .then(function (data) {649 var updated = _.merge(data, customer);650 result.updated = updated;651 return result;652 });653 })654 .then(function (result) {655 var updated = result.updated;656 return updated.save().then(function () {657 result.customers[0][0] = updated;658 return result;659 });660 })661 .then(function (result) {662 var building = result.buildings[0];663 var contracts = result.contracts[0];664 var units = result.units[0];665 var customers = result.customers[0];666 contracts.forEach(function (contract) {667 building.contracts.push(contract);668 })669 units.forEach(function (unit) {670 building.units.push(unit);671 })672 customers.forEach(function (customer) {673 building.customers.push(customer);674 })675 return Building.findById(building._id).exec()676 .then(function (data) {677 var updated = _.merge(data, building);678 result.updated = updated;679 return result;680 });681 })682 .then(function (result) {683 var updated = result.updated;684 return updated.save().then(function () {685 result.buildings[0] = updated;686 return result;687 });688 })689 .then(function (result) {690 return Unit.create({691 local: 1,692 surface: 132,693 type: 'Bodega',694 description: '',695 ocupated: false,696 building: result.buildings[1]697 })698 .then(function (unit) {699 result.units.push([unit]);700 return result;701 });702 })703 .then(function (result) {704 return Unit.create({705 local: 2,706 surface: 132,707 type: 'Bodega',708 description: '',709 ocupated: false,710 building: result.buildings[1]711 })712 .then(function (unit) {713 result.units[1].push(unit);714 return result;715 });716 })717 .then(function (result) {718 return Unit.create({719 local: 3,720 surface: 132,721 type: 'Bodega',722 description: '',723 ocupated: false,724 building: result.buildings[1]725 })726 .then(function (unit) {727 result.units[1].push(unit);728 return result;729 });730 })731 .then(function (result) {732 return Customer.create({733 name: 'STR AUTOMATION, S.A. DE C.V',734 tradename: 'STR AUTOMATION, S.A. DE C.V',735 rfc: 'SAU070425CU6',736 address: 'Ave Tecnologico No. 1345-5',737 neiborhood: 'Los Olmos',738 zipCode: '32510',739 city: 'Juarez',740 state: 'Chihuahua',741 country: 'Mexico',742 representative: 'Rogelio Valenzuela Renteria',743 email: 'fmiranda@akbalsc.com',744 currency: 'dolares',745 building: result.buildings[1]746 })747 .then(function (customer) {748 result.customers.push([customer]);749 return result;750 });751 })752 .then(function (result) {753 return Customer.create({754 name: 'CARLOS ABRAHAM PORTILLO GARIBAY',755 tradename: 'CARLOS ABRAHAM PORTILLO GARIBAY',756 rfc: 'POGC8204267E4',757 address: 'Ramon Rivera Lara No. 6005-3',758 neiborhood: 'Partido Iglesias',759 zipCode: '32663',760 city: 'Juarez',761 state: 'Chihuahua',762 country: 'Mexico',763 representative: 'Carlos Abraham Portillo Garibay',764 email: 'fmiranda@akbalsc.com',765 currency: 'dolares',766 building: result.buildings[1]767 })768 .then(function (customer) {769 result.customers[1].push(customer);770 return result;771 });772 })773 .then(function (result) {774 return Contract.create({775 startDate: new Date(2015,6,1),776 endDate: new Date(2016,5,30),777 monthlyRent: '858',778 taxRate: 16,779 currency: 'dolares',780 paymentMethod: 'Transferencia Electronica',781 deposit: '',782 maintenanceFee: '75',783 taxOverdue: '',784 marginsDay: 10,785 building: result.buildings[1],786 unit: result.units[1][0],787 customer: result.customers[1][0],788 })789 .then(function (contract) {790 result.contracts.push([contract]);791 result.units[1][0].contracts.push(contract);792 result.customers[1][0].contracts.push(contract);793 return result;794 });795 })796 .then(function (result) {797 var unit = result.units[1][0];798 return Unit.findById(unit._id).exec()799 .then(function (data) {800 var updated = _.merge(data, unit);801 result.updated = updated;802 return result;803 });804 })805 .then(function (result) {806 var updated = result.updated;807 return updated.save().then(function () {808 result.units[1][0] = updated;809 return result;810 });811 })812 // .then(function (result) {813 // var customer = result.customers[1][0];814 // return Customer.findById(customer._id).exec()815 // .then(function (data) {816 // var updated = _.merge(data, customer);817 // result.updated = updated;818 // return result;819 // });820 // })821 // .then(function (result) {822 // var updated = result.updated;823 // return updated.save().then(function () {824 // result.customers[1][0] = updated;825 // return result;826 // });827 // })828 .then(function (result) {829 return Contract.create({830 startDate: new Date(2014,7,1),831 endDate: new Date(2015,6,31),832 monthlyRent: '858',833 taxRate: 16,834 currency: 'pesos',835 paymentMethod: 'Transferencia Electronica',836 deposit: '',837 maintenanceFee: '75',838 taxOverdue: '',839 marginsDay: 10,840 building: result.buildings[1],841 unit: result.units[1][1],842 customer: result.customers[1][0],843 })844 .then(function (contract) {845 result.contracts[1].push(contract);846 result.units[1][1].contracts.push(contract);847 result.customers[1][0].contracts.push(contract);848 return result;849 });850 })851 .then(function (result) {852 var unit = result.units[1][1];853 return Unit.findById(unit._id).exec()854 .then(function (data) {855 var updated = _.merge(data, unit);856 result.updated = updated;857 return result;858 });859 })860 .then(function (result) {861 var updated = result.updated;862 return updated.save().then(function () {863 result.units[1][1] = updated;864 return result;865 });866 })867 .then(function (result) {868 var customer = result.customers[1][0];869 return Customer.findById(customer._id).exec()870 .then(function (data) {871 var updated = _.merge(data, customer);872 result.updated = updated;873 return result;874 });875 })876 .then(function (result) {877 var updated = result.updated;878 return updated.save().then(function () {879 result.customers[1][0] = updated;880 return result;881 });882 })883 .then(function (result) {884 return Contract.create({885 startDate: new Date(2015,0,1),886 endDate: new Date(2016,11,1),887 monthlyRent: '924',888 taxRate: 16,889 currency: 'dolares',890 paymentMethod: 'Transferencia Electronica',891 deposit: '',892 maintenanceFee: '92.4',893 taxOverdue: '',894 marginsDay: 10,895 building: result.buildings[1],896 unit: result.units[1][2],897 customer: result.customers[1][1],898 })899 .then(function (contract) {900 result.contracts[1].push(contract);901 result.units[1][2].contracts.push(contract);902 result.customers[1][1].contracts.push(contract);903 return result;904 });905 })906 .then(function (result) {907 var unit = result.units[1][2];908 return Unit.findById(unit._id).exec()909 .then(function (data) {910 var updated = _.merge(data, unit);911 result.updated = updated;912 return result;913 });914 })915 .then(function (result) {916 var updated = result.updated;917 return updated.save().then(function () {918 result.units[1][2] = updated;919 return result;920 });921 })922 .then(function (result) {923 var customer = result.customers[1][1];924 return Customer.findById(customer._id).exec()925 .then(function (data) {926 var updated = _.merge(data, customer);927 result.updated = updated;928 return result;929 });930 })931 .then(function (result) {932 var updated = result.updated;933 return updated.save().then(function () {934 result.customers[1][1] = updated;935 return result;936 });937 })938 .then(function (result) {939 var building = result.buildings[1];940 var contracts = result.contracts[1];941 var units = result.units[1];942 var customers = result.customers[1];943 contracts.forEach(function (contract) {944 building.contracts.push(contract);945 })946 units.forEach(function (unit) {947 building.units.push(unit);948 })949 customers.forEach(function (customer) {950 building.customers.push(customer);951 })952 return Building.findById(building._id).exec()953 .then(function (data) {954 var updated = _.merge(data, building);955 result.updated = updated;956 return result;957 });958 })959 .then(function (result) {960 var updated = result.updated;961 return updated.save().then(function () {962 result.buildings[1] = updated;963 return result;964 });965 })966 .then(function (result) {967 return Unit.create({968 local: 2,969 surface: 66,970 type: 'Oficina',971 description: '',972 ocupated: false,973 building: result.buildings[2]974 })975 .then(function (unit) {976 result.units.push([unit]);977 return result;978 });979 })980 .then(function (result) {981 return Unit.create({982 local: 3,983 surface: 66,984 type: 'Oficina',985 description: '',986 ocupated: false,987 building: result.buildings[2]988 })989 .then(function (unit) {990 result.units[2].push(unit);991 return result;992 });993 })994 .then(function (result) {995 return Unit.create({996 local: 4,997 surface: 66,998 type: 'Oficina',999 description: '',1000 ocupated: false,1001 building: result.buildings[2]1002 })1003 .then(function (unit) {1004 result.units[2].push(unit);1005 return result;1006 });1007 })1008 .then(function (result) {1009 return Unit.create({1010 local: 5,1011 surface: 73,1012 type: 'Oficina',1013 description: '',1014 ocupated: false,1015 building: result.buildings[2]1016 })1017 .then(function (unit) {1018 result.units[2].push(unit);1019 return result;1020 });1021 })1022 .then(function (result) {1023 return Unit.create({1024 local: 6,1025 surface: 96,1026 type: 'Oficina',1027 description: '',1028 ocupated: false,1029 building: result.buildings[2]1030 })1031 .then(function (unit) {1032 result.units[2].push(unit);1033 return result;1034 });1035 })1036 .then(function (result) {1037 return Unit.create({1038 local: 7,1039 surface: 154,1040 type: 'Oficina',1041 description: '',1042 ocupated: false,1043 building: result.buildings[2]1044 })1045 .then(function (unit) {1046 result.units[2].push(unit);1047 return result;1048 });1049 })1050 .then(function (result) {1051 return Unit.create({1052 local: 8,1053 surface: 66,1054 type: 'Oficina',1055 description: '',1056 ocupated: false,1057 building: result.buildings[2]1058 })1059 .then(function (unit) {1060 result.units[2].push(unit);1061 return result;1062 });1063 })1064 .then(function (result) {1065 return Unit.create({1066 local: 9,1067 surface: 66,1068 type: 'Oficina',1069 description: '',1070 ocupated: false,1071 building: result.buildings[2]1072 })1073 .then(function (unit) {1074 result.units[2].push(unit);1075 return result;1076 });1077 })1078 .then(function (result) {1079 return Unit.create({1080 local: 10,1081 surface: 66,1082 type: 'Oficina',1083 description: '',1084 ocupated: false,1085 building: result.buildings[2]1086 })1087 .then(function (unit) {1088 result.units[2].push(unit);1089 return result;1090 });1091 })1092 .then(function (result) {1093 return Unit.create({1094 local: 11,1095 surface: 66,1096 type: 'Oficina',1097 description: '',1098 ocupated: false,1099 building: result.buildings[2]1100 })1101 .then(function (unit) {1102 result.units[2].push(unit);1103 return result;1104 });1105 })1106 .then(function (result) {1107 return Customer.create({1108 name: 'GME TECHNOLOGY DE MEXICO, S.A. DE C.V.',1109 tradename: 'GME TECHNOLOGY DE MEXICO, S.A. DE C.V.',1110 rfc: 'GTM1012091K1',1111 address: 'Blvd. Manuel Gomez Morin No. 9321-2',1112 neiborhood: 'Partido Senecú',1113 zipCode: '32470',1114 city: 'Juarez',1115 state: 'Chihuahua',1116 country: 'Mexico',1117 representative: 'Irma Lizeth Alamillo Soto',1118 email: 'fmiranda@akbalsc.com',1119 currency: 'dolares',1120 building: result.buildings[2]1121 })1122 .then(function (customer) {1123 result.customers.push([customer]);1124 return result;1125 });1126 })1127 .then(function (result) {1128 return Customer.create({1129 name: 'INMOBILIARIA M M S DE RL DE CV',1130 tradename: 'INMOBILIARIA M M S DE RL DE CV',1131 rfc: 'IUM150406KTA',1132 address: 'Camino Escudero No. 9400',1133 neiborhood: 'Hacienda De La Paloma',1134 zipCode: '32545',1135 city: 'Juarez',1136 state: 'Chihuahua',1137 country: 'Mexico',1138 representative: 'Marco Antonio Ceniceros Cisneros',1139 email: 'fmiranda@akbalsc.com',1140 currency: 'dolares',1141 building: result.buildings[2]1142 })1143 .then(function (customer) {1144 result.customers[2].push(customer);1145 return result;1146 });1147 })1148 .then(function (result) {1149 return Customer.create({1150 name: 'SERVICIO INDUSTRIAL DE COMEDORES, S.A. DE C.V.',1151 tradename: 'SERVICIO INDUSTRIAL DE COMEDORES, S.A. DE C.V.',1152 rfc: 'SIC701029BL4',1153 address: 'Blvd. Manuel Gomez Morin No. 9321-4',1154 neiborhood: 'Col. Fray Garcia De San Francisco',1155 zipCode: '32575',1156 city: 'Juarez',1157 state: 'Chihuahua',1158 country: 'Mexico',1159 representative: 'Juan Antonio Perez Vazquez',1160 email: 'fmiranda@akbalsc.com',1161 currency: 'dolares',1162 building: result.buildings[2]1163 })1164 .then(function (customer) {1165 result.customers[2].push(customer);1166 return result;1167 });1168 })1169 .then(function (result) {1170 return Customer.create({1171 name: 'INMOBILIARIA ESCOBAR, VALDEZ Y HERMANOS, S.A DE C.V.',1172 tradename: 'INMOBILIARIA ESCOBAR, VALDEZ Y HERMANOS, S.A DE C.V.',1173 rfc: 'IEV9304053V4',1174 address: 'Blvd. Manuel Gomez Morin No. 9321-6',1175 neiborhood: 'Col. Fray Garcia De San Francisco',1176 zipCode: '32575',1177 city: 'Juarez',1178 state: 'Chihuahua',1179 country: 'Mexico',1180 representative: 'Pedro Sanchez Ramirez',1181 email: 'fmiranda@akbalsc.com',1182 currency: 'dolares',1183 building: result.buildings[2]1184 })1185 .then(function (customer) {1186 result.customers[2].push(customer);1187 return result;1188 });1189 })1190 .then(function (result) {1191 return Customer.create({1192 name: 'LABORATORIOS PISA, S.A. DE C.V.',1193 tradename: 'LABORATORIOS PISA, S.A. DE C.V.',1194 rfc: 'LPI830527KJ2',1195 address: 'Av. España No. 1840',1196 neiborhood: 'Col. Moderna',1197 zipCode: '44190',1198 city: 'Guadalajara',1199 state: 'Jalisco',1200 country: 'Mexico',1201 representative: 'Oscar Osorio Arechavaleta',1202 email: 'fmiranda@akbalsc.com',1203 currency: 'dolares',1204 building: result.buildings[2]1205 })1206 .then(function (customer) {1207 result.customers[2].push(customer);1208 return result;1209 });1210 })1211 .then(function (result) {1212 return Customer.create({1213 name: 'GERARDO RECIO GONZALEZ',1214 tradename: 'GERARDO RECIO GONZALEZ',1215 rfc: 'REGG550327EH4',1216 address: 'Blvd. Manuel Gomez Morin No. 9321-8',1217 neiborhood: 'Partido Senecú',1218 zipCode: '32470',1219 city: 'Juarez',1220 state: 'Chihuahua',1221 country: 'Mexico',1222 representative: 'Gerardo Recio Gonzalez',1223 email: 'fmiranda@akbalsc.com',1224 currency: 'dolares',1225 building: result.buildings[2]1226 })1227 .then(function (customer) {1228 result.customers[2].push(customer);1229 return result;1230 });1231 })1232 .then(function (result) {1233 return Customer.create({1234 name: 'TAMPOMEX, S.A. DE C.V.',1235 tradename: 'TAMPOMEX, S.A. DE C.V.',1236 rfc: 'TAM0002016K9',1237 address: 'Industria Vidriera No. 115',1238 neiborhood: 'Fracc. Industrial Zapopan Norte',1239 zipCode: '45132',1240 city: 'Zapopan',1241 state: 'Jalisco',1242 country: 'Mexico',1243 representative: 'Jorge Javier Arciniega Jimenez',1244 email: 'fmiranda@akbalsc.com',1245 currency: 'dolares',1246 building: result.buildings[2]1247 })1248 .then(function (customer) {1249 result.customers[2].push(customer);1250 return result;1251 });1252 })1253 .then(function (result) {1254 return Customer.create({1255 name: 'GERARDO SILVA HERNANDEZ',1256 tradename: 'GERARDO SILVA HERNANDEZ',1257 rfc: 'XAXX010101000',1258 address: 'Simona Barba No. 5110-19',1259 neiborhood: 'Partido Escobedo',1260 zipCode: '32330',1261 city: 'Juarez',1262 state: 'Chihuahua',1263 country: 'Mexico',1264 representative: 'Representante Legal',1265 email: 'fmiranda@akbalsc.com',1266 currency: 'dolares',1267 building: result.buildings[2]1268 })1269 .then(function (customer) {1270 result.customers[2].push(customer);1271 return result;1272 });1273 })1274 .then(function (result) {1275 return Customer.create({1276 name: 'TRANQUILINO ROCHA ESPINOZA',1277 tradename: 'TRANQUILINO ROCHA ESPINOZA',1278 rfc: 'ROET680129ID7',1279 address: 'Blvd. Manuel Gomez Morin No. 9321-11',1280 neiborhood: 'Condominio Residencial San Francisco',1281 zipCode: '32330',1282 city: 'Juarez',1283 state: 'Chihuahua',1284 country: 'Mexico',1285 representative: 'Tranquilino Rocha Espinoza',1286 email: 'fmiranda@akbalsc.com',1287 currency: 'pesos',1288 building: result.buildings[2]1289 })1290 .then(function (customer) {1291 result.customers[2].push(customer);1292 return result;1293 });1294 })1295 .then(function (result) {1296 var building = result.buildings[2];1297 var units = result.units[2];1298 var customers = result.customers[2];1299 units.forEach(function (unit) {1300 building.units.push(unit);1301 })1302 customers.forEach(function (customer) {1303 building.customers.push(customer);1304 })1305 return Building.findById(building._id).exec()1306 .then(function (data) {1307 var updated = _.merge(data, building);1308 result.updated = updated;1309 return result;1310 });1311 })1312 .then(function (result) {1313 var updated = result.updated;1314 return updated.save().then(function () {1315 result.buildings[2] = updated;1316 return result;1317 });1318 })1319 .then(function (result) {1320 return Unit.create({1321 local: 1,1322 surface: 60,1323 type: 'Oficina',1324 description: '',1325 ocupated: false,1326 building: result.buildings[3]1327 })1328 .then(function (unit) {1329 result.units.push([unit]);1330 return result;1331 });1332 })1333 .then(function (result) {1334 return Unit.create({1335 local: 2,1336 surface: 60,1337 type: 'Oficina',1338 description: '',1339 ocupated: false,1340 building: result.buildings[3]1341 })1342 .then(function (unit) {1343 result.units[3].push(unit);1344 return result;1345 });1346 })1347 .then(function (result) {1348 return Unit.create({1349 local: 3,1350 surface: 60,1351 type: 'Oficina',1352 description: '',1353 ocupated: false,1354 building: result.buildings[3]1355 })1356 .then(function (unit) {1357 result.units[3].push(unit);1358 return result;1359 });1360 })1361 .then(function (result) {1362 return Unit.create({1363 local: 4,1364 surface: 60,1365 type: 'Oficina',1366 description: '',1367 ocupated: false,1368 building: result.buildings[3]1369 })1370 .then(function (unit) {1371 result.units[3].push(unit);1372 return result;1373 });1374 })1375 .then(function (result) {1376 return Unit.create({1377 local: 5,1378 surface: 60,1379 type: 'Oficina',1380 description: '',1381 ocupated: false,1382 building: result.buildings[3]1383 })1384 .then(function (unit) {1385 result.units[3].push(unit);1386 return result;1387 });1388 })1389 .then(function (result) {1390 return Unit.create({1391 local: 6,1392 surface: 60,1393 type: 'Oficina',1394 description: '',1395 ocupated: false,1396 building: result.buildings[3]1397 })1398 .then(function (unit) {1399 result.units[3].push(unit);1400 return result;1401 });1402 })1403 .then(function (result) {1404 return Unit.create({1405 local: 8,1406 surface: 168,1407 type: 'Oficina',1408 description: '',1409 ocupated: false,1410 building: result.buildings[3]1411 })1412 .then(function (unit) {1413 result.units[3].push(unit);1414 return result;1415 });1416 })1417 .then(function (result) {1418 return Unit.create({1419 local: 9,1420 surface: 67,1421 type: 'Oficina',1422 description: '',1423 ocupated: false,1424 building: result.buildings[3]1425 })1426 .then(function (unit) {1427 result.units[3].push(unit);1428 return result;1429 });1430 })1431 .then(function (result) {1432 return Unit.create({1433 local: 10,1434 surface: 63.5,1435 type: 'Oficina',1436 description: '',1437 ocupated: false,1438 building: result.buildings[3]1439 })1440 .then(function (unit) {1441 result.units[3].push(unit);1442 return result;1443 });1444 })1445 .then(function (result) {1446 return Unit.create({1447 local: 11,1448 surface: 57,1449 type: 'Oficina',1450 description: '',1451 ocupated: false,1452 building: result.buildings[3]1453 })1454 .then(function (unit) {1455 result.units[3].push(unit);1456 return result;1457 });1458 })1459 .then(function (result) {1460 return Unit.create({1461 local: 12,1462 surface: 54,1463 type: 'Oficina',1464 description: '',1465 ocupated: false,1466 building: result.buildings[3]1467 })1468 .then(function (unit) {1469 result.units[3].push(unit);1470 return result;1471 });1472 })1473 .then(function (result) {1474 return Unit.create({1475 local: 13,1476 surface: 129,1477 type: 'Oficina',1478 description: '',1479 ocupated: false,1480 building: result.buildings[3]1481 })1482 .then(function (unit) {1483 result.units[3].push(unit);1484 return result;1485 });1486 })1487 .then(function (result) {1488 return Unit.create({1489 local: 14,1490 surface: 60,1491 type: 'Oficina',1492 description: '',1493 ocupated: false,1494 building: result.buildings[3]1495 })1496 .then(function (unit) {1497 result.units[3].push(unit);1498 return result;1499 });1500 })1501 .then(function (result) {1502 return Unit.create({1503 local: 15,1504 surface: 60,1505 type: 'Oficina',1506 description: '',1507 ocupated: false,1508 building: result.buildings[3]1509 })1510 .then(function (unit) {1511 result.units[3].push(unit);1512 return result;1513 });1514 })1515 .then(function (result) {1516 return Unit.create({1517 local: 16,1518 surface: 60,1519 type: 'Oficina',1520 description: '',1521 ocupated: false,1522 building: result.buildings[3]1523 })1524 .then(function (unit) {1525 result.units[3].push(unit);1526 return result;1527 });1528 })1529 .then(function (result) {1530 return Unit.create({1531 local: 17,1532 surface: 60,1533 type: 'Oficina',1534 description: '',1535 ocupated: false,1536 building: result.buildings[3]1537 })1538 .then(function (unit) {1539 result.units[3].push(unit);1540 return result;1541 });1542 })1543 .then(function (result) {1544 return Unit.create({1545 local: 18,1546 surface: 60,1547 type: 'Oficina',1548 description: '',1549 ocupated: false,1550 building: result.buildings[3]1551 })1552 .then(function (unit) {1553 result.units[3].push(unit);1554 return result;1555 });1556 })1557 .then(function (result) {1558 return Unit.create({1559 local: 19,1560 surface: 60,1561 type: 'Oficina',1562 description: '',1563 ocupated: false,1564 building: result.buildings[3]1565 })1566 .then(function (unit) {1567 result.units[3].push(unit);1568 return result;1569 });1570 })1571 .then(function (result) {1572 return Unit.create({1573 local: 20,1574 surface: 60,1575 type: 'Oficina',1576 description: '',1577 ocupated: false,1578 building: result.buildings[3]1579 })1580 .then(function (unit) {1581 result.units[3].push(unit);1582 return result;1583 });1584 })1585 .then(function (result) {1586 return Unit.create({1587 local: 21,1588 surface: 60,1589 type: 'Oficina',1590 description: '',1591 ocupated: false,1592 building: result.buildings[3]1593 })1594 .then(function (unit) {1595 result.units[3].push(unit);1596 return result;1597 });1598 })1599 .then(function (result) {1600 return Unit.create({1601 local: 22,1602 surface: 60,1603 type: 'Oficina',1604 description: '',1605 ocupated: false,1606 building: result.buildings[3]1607 })1608 .then(function (unit) {1609 result.units[3].push(unit);1610 return result;1611 });1612 })1613 .then(function (result) {1614 return Unit.create({1615 local: 23,1616 surface: 60,1617 type: 'Oficina',1618 description: '',1619 ocupated: false,1620 building: result.buildings[3]1621 })1622 .then(function (unit) {1623 result.units[3].push(unit);1624 return result;1625 });1626 })1627 .then(function (result) {1628 return Unit.create({1629 local: 24,1630 surface: 60,1631 type: 'Oficina',1632 description: '',1633 ocupated: false,1634 building: result.buildings[3]1635 })1636 .then(function (unit) {1637 result.units[3].push(unit);1638 return result;1639 });1640 })1641 .then(function (result) {1642 return Unit.create({1643 local: 26,1644 surface: 170,1645 type: 'Oficina',1646 description: '',1647 ocupated: false,1648 building: result.buildings[3]1649 })1650 .then(function (unit) {1651 result.units[3].push(unit);1652 return result;1653 });1654 })1655 .then(function (result) {1656 return Unit.create({1657 local: 27,1658 surface: 68,1659 type: 'Oficina',1660 description: '',1661 ocupated: false,1662 building: result.buildings[3]1663 })1664 .then(function (unit) {1665 result.units[3].push(unit);1666 return result;1667 });1668 })1669 .then(function (result) {1670 return Unit.create({1671 local: 28,1672 surface: 64.5,1673 type: 'Oficina',1674 description: '',1675 ocupated: false,1676 building: result.buildings[3]1677 })1678 .then(function (unit) {1679 result.units[3].push(unit);1680 return result;1681 });1682 })1683 .then(function (result) {1684 return Unit.create({1685 local: 29,1686 surface: 60,1687 type: 'Oficina',1688 description: '',1689 ocupated: false,1690 building: result.buildings[3]1691 })1692 .then(function (unit) {1693 result.units[3].push(unit);1694 return result;1695 });1696 })1697 .then(function (result) {1698 return Unit.create({1699 local: 30,1700 surface: 60,1701 type: 'Oficina',1702 description: '',1703 ocupated: false,1704 building: result.buildings[3]1705 })1706 .then(function (unit) {1707 result.units[3].push(unit);1708 return result;1709 });1710 })1711 .then(function (result) {1712 return Unit.create({1713 local: 31,1714 surface: 131,1715 type: 'Oficina',1716 description: '',1717 ocupated: false,1718 building: result.buildings[3]1719 })1720 .then(function (unit) {1721 result.units[3].push(unit);1722 return result;1723 });1724 })1725 .then(function (result) {1726 return Unit.create({1727 local: 32,1728 surface: 60,1729 type: 'Oficina',1730 description: '',1731 ocupated: false,1732 building: result.buildings[3]1733 })1734 .then(function (unit) {1735 result.units[3].push(unit);1736 return result;1737 });1738 })1739 .then(function (result) {1740 return Unit.create({1741 local: 33,1742 surface: 60,1743 type: 'Oficina',1744 description: '',1745 ocupated: false,1746 building: result.buildings[3]1747 })1748 .then(function (unit) {1749 result.units[3].push(unit);1750 return result;1751 });1752 })1753 .then(function (result) {1754 return Unit.create({1755 local: 34,1756 surface: 60,1757 type: 'Oficina',1758 description: '',1759 ocupated: false,1760 building: result.buildings[3]1761 })1762 .then(function (unit) {1763 result.units[3].push(unit);1764 return result;1765 });1766 })1767 .then(function (result) {1768 return Unit.create({1769 local: 35,1770 surface: 60,1771 type: 'Oficina',1772 description: '',1773 ocupated: false,1774 building: result.buildings[3]1775 })1776 .then(function (unit) {1777 result.units[3].push(unit);1778 return result;1779 });1780 })1781 .then(function (result) {1782 return Unit.create({1783 local: 36,1784 surface: 60,1785 type: 'Oficina',1786 description: '',1787 ocupated: false,1788 building: result.buildings[3]1789 })1790 .then(function (unit) {1791 result.units[3].push(unit);1792 return result;1793 });1794 })1795 .then(function (result) {1796 return Unit.create({1797 local: 37,1798 surface: 60,1799 type: 'Oficina',1800 description: '',1801 ocupated: false,1802 building: result.buildings[3]1803 })1804 .then(function (unit) {1805 result.units[3].push(unit);1806 return result;1807 });1808 })1809 .then(function (result) {1810 return Unit.create({1811 local: 38,1812 surface: 60,1813 type: 'Oficina',1814 description: '',1815 ocupated: false,1816 building: result.buildings[3]1817 })1818 .then(function (unit) {1819 result.units[3].push(unit);1820 return result;1821 });1822 })1823 .then(function (result) {1824 return Unit.create({1825 local: 39,1826 surface: 60,1827 type: 'Oficina',1828 description: '',1829 ocupated: false,1830 building: result.buildings[3]1831 })1832 .then(function (unit) {1833 result.units[3].push(unit);1834 return result;1835 });1836 })1837 .then(function (result) {1838 return Customer.create({1839 name: 'DISTRIBUIDORA REYES G, S.A. DE C.V.',1840 tradename: 'DISTRIBUIDORA REYES G, S.A. DE C.V.',1841 rfc: 'DRG810506I80',1842 address: 'Simona Barba No. 5110-2',1843 neiborhood: 'Partido Escobedo',1844 zipCode: '32330',1845 city: 'Juarez',1846 state: 'Chihuahua',1847 country: 'Mexico',1848 representative: 'Lic. Javier Reyes Ramirez',1849 email: 'fmiranda@akbalsc.com',1850 currency: 'pesos',1851 building: result.buildings[3]1852 })1853 .then(function (customer) {1854 result.customers.push([customer]);1855 return result;1856 });1857 })1858 .then(function (result) {1859 return Customer.create({1860 name: 'CORPORATIVO LABGI, S.C.',1861 tradename: 'CORPORATIVO LABGI, S.C.',1862 rfc: 'CLA130823CI2',1863 address: 'Calzada Estadio Sur No. 333 B-39',1864 neiborhood: 'Centro',1865 zipCode: '27000',1866 city: 'Torreon',1867 state: 'Coahuila',1868 country: 'Mexico',1869 representative: 'Maria Loreto Gonzalez Marquez',1870 email: 'fmiranda@akbalsc.com',1871 currency: 'pesos',1872 building: result.buildings[3]1873 })1874 .then(function (customer) {1875 result.customers[3].push(customer);1876 return result;1877 });1878 })1879 .then(function (result) {1880 return Customer.create({1881 name: 'HR SERVICES, S.C.',1882 tradename: 'HR SERVICES, S.C.',1883 rfc: 'HSE021005BY8',1884 address: 'Simona Barba No. 5110-10',1885 neiborhood: 'Partido Escobedo',1886 zipCode: '32330',1887 city: 'Juarez',1888 state: 'Chihuahua',1889 country: 'Mexico',1890 representative: 'Ricardo Weichsel Upton',1891 email: 'fmiranda@akbalsc.com',1892 currency: 'pesos',1893 building: result.buildings[3]1894 })1895 .then(function (customer) {1896 result.customers[3].push(customer);1897 return result;1898 });1899 })1900 .then(function (result) {1901 return Customer.create({1902 name: 'ARMANDO MANRIQUEZ RUIZ',1903 tradename: 'ARMANDO MANRIQUEZ RUIZ',1904 rfc: 'MARA570217V94',1905 address: 'Calle Juan José Escudero No. 2507-A',1906 neiborhood: 'Santo Niño',1907 zipCode: '31200',1908 city: 'Chihuahua',1909 state: 'Chihuahua',1910 country: 'Mexico',1911 representative: 'Armando Manriquez Ruiz',1912 email: 'fmiranda@akbalsc.com',1913 currency: 'pesos',1914 building: result.buildings[3]1915 })1916 .then(function (customer) {1917 result.customers[3].push(customer);1918 return result;1919 });1920 })1921 .then(function (result) {1922 return Customer.create({1923 name: 'CONSULTORIA AKBAL, S.C.',1924 tradename: 'CONSULTORIA AKBAL, S.C.',1925 rfc: 'CAK971001JU8',1926 address: 'Simona Barba No. 5110-18',1927 neiborhood: 'Partido Escobedo',1928 zipCode: '32330',1929 city: 'Juarez',1930 state: 'Chihuahua',1931 country: 'Mexico',1932 representative: 'Mario Cepeda Lucero',1933 email: 'fmiranda@akbalsc.com',1934 currency: 'pesos',1935 building: result.buildings[3]1936 })1937 .then(function (customer) {1938 result.customers[3].push(customer);1939 return result;1940 });1941 })1942 .then(function (result) {1943 return Customer.create({1944 name: 'RAFAEL RIVERA RODRIGUEZ',1945 tradename: 'RAFAEL RIVERA RODRIGUEZ',1946 rfc: 'RIRR620221SG3',1947 address: 'Simona Barba No. 5110-8',1948 neiborhood: 'Partido Escobedo',1949 zipCode: '32330',1950 city: 'Juarez',1951 state: 'Chihuahua',1952 country: 'Mexico',1953 representative: 'Rafael Rivera Rodriguez',1954 email: 'fmiranda@akbalsc.com',1955 currency: 'pesos',1956 building: result.buildings[3]1957 })1958 .then(function (customer) {1959 result.customers[3].push(customer);1960 return result;1961 });1962 })1963 .then(function (result) {1964 return Customer.create({1965 name: 'MANTENIMIENTO PROFESIONAL DE INTERIORES, S.A. DE C.V.',1966 tradename: 'MANTENIMIENTO PROFESIONAL DE INTERIORES, S.A. DE C.V.',1967 rfc: 'MPI9711247J6',1968 address: 'Simona Barba No. 5110-9',1969 neiborhood: 'Partido Escobedo',1970 zipCode: '32330',1971 city: 'Juarez',1972 state: 'Chihuahua',1973 country: 'Mexico',1974 representative: 'Ana Maria Ruiz Soto',1975 email: 'fmiranda@akbalsc.com',1976 currency: 'pesos',1977 building: result.buildings[3]1978 })1979 .then(function (customer) {1980 result.customers[3].push(customer);1981 return result;1982 });1983 })1984 .then(function (result) {1985 return Customer.create({1986 name: 'EXPRESO TRAVEL AND TOURS',1987 tradename: 'EXPRESO TRAVEL AND TOURS',1988 rfc: 'XAXX010101000',1989 address: 'Simona Barba No. 5110-19',1990 neiborhood: 'Partido Escobedo',1991 zipCode: '32330',1992 city: 'Juarez',1993 state: 'Chihuahua',1994 country: 'Mexico',1995 representative: 'Representante Legal',1996 email: 'fmiranda@akbalsc.com',1997 currency: 'pesos',1998 building: result.buildings[3]1999 })2000 .then(function (customer) {2001 result.customers[3].push(customer);2002 return result;2003 });2004 })2005 .then(function (result) {2006 return Customer.create({2007 name: 'MHO TECNOLOGIA, S. DE R.L. DE C.V.',2008 tradename: 'MHO TECNOLOGIA, S. DE R.L. DE C.V.',2009 rfc: 'XAXX010101000',2010 address: 'Simona Barba No. 5110-19',2011 neiborhood: 'Partido Escobedo',2012 zipCode: '32330',2013 city: 'Juarez',2014 state: 'Chihuahua',2015 country: 'Mexico',2016 representative: 'Representante Legal',2017 email: 'fmiranda@akbalsc.com',2018 currency: 'pesos',2019 building: result.buildings[3]2020 })2021 .then(function (customer) {2022 result.customers[3].push(customer);2023 return result;2024 });2025 })2026 .then(function (result) {2027 return Customer.create({2028 name: 'TRANSPORTES ALGOZA DEL NORTE, S.A. DE C.V.',2029 tradename: 'TRANSPORTES ALGOZA DEL NORTE, S.A. DE C.V.',2030 rfc: 'TAN950901T88',2031 address: 'Simona Barba No. 5110-12',2032 neiborhood: 'Partido Escobedo',2033 zipCode: '32330',2034 city: 'Juarez',2035 state: 'Chihuahua',2036 country: 'Mexico',2037 representative: 'Cesar Gonzalez Zapata',2038 email: 'fmiranda@akbalsc.com',2039 currency: 'pesos',2040 building: result.buildings[3]2041 })2042 .then(function (customer) {2043 result.customers[3].push(customer);2044 return result;2045 });2046 })2047 .then(function (result) {2048 return Customer.create({2049 name: 'AXCEL TODO PARA SU CELULAR, S.A. DE C.V.',2050 tradename: 'AXCEL TODO PARA SU CELULAR, S.A. DE C.V.',2051 rfc: 'ATS930412TY6',2052 address: 'Plutarco Elias Calles No. 1972',2053 neiborhood: 'Fracc. Jardines De San Jose',2054 zipCode: '32390',2055 city: 'Juarez',2056 state: 'Chihuahua',2057 country: 'Mexico',2058 representative: 'Ruben Arnoldo Rivera Chavira',2059 email: 'fmiranda@akbalsc.com',2060 currency: 'pesos',2061 building: result.buildings[3]2062 })2063 .then(function (customer) {2064 result.customers[3].push(customer);2065 return result;2066 });2067 })2068 .then(function (result) {2069 return Customer.create({2070 name: 'EDGAR MONTOYA ZAVALA',2071 tradename: 'EDGAR MONTOYA ZAVALA',2072 rfc: 'XAXX010101000',2073 address: 'Simona Barba No. 5110-19',2074 neiborhood: 'Partido Escobedo',2075 zipCode: '32330',2076 city: 'Juarez',2077 state: 'Chihuahua',2078 country: 'Mexico',2079 representative: 'Representante Legal',2080 email: 'fmiranda@akbalsc.com',2081 currency: 'pesos',2082 building: result.buildings[3]2083 })2084 .then(function (customer) {2085 result.customers[3].push(customer);2086 return result;2087 });2088 })2089 .then(function (result) {2090 return Customer.create({2091 name: 'KHNUM, S.A. DE C.V.',2092 tradename: 'KHNUM, S.A. DE C.V.',2093 rfc: 'KHN131019UR7',2094 address: 'Simona Barba No. 5110-15',2095 neiborhood: 'San Angel',2096 zipCode: '32389',2097 city: 'Juarez',2098 state: 'Chihuahua',2099 country: 'Mexico',2100 representative: 'Luz Elva Mendoza Morales',2101 email: 'fmiranda@akbalsc.com',2102 currency: 'pesos',2103 building: result.buildings[3]2104 })2105 .then(function (customer) {2106 result.customers[3].push(customer);2107 return result;2108 });2109 })2110 .then(function (result) {2111 return Customer.create({2112 name: 'GRUPO RAOSARI, S DE RL DE CV',2113 tradename: 'GRUPO RAOSARI, S DE RL DE CV',2114 rfc: 'GRA031212589',2115 address: 'Privada De Vallarta Y Sicomoros No. 5501',2116 neiborhood: 'Las Granjas',2117 zipCode: '31160',2118 city: 'Chihuahua',2119 state: 'Chihuahua',2120 country: 'Mexico',2121 representative: 'Jesus Joel Cereceres Granillo',2122 email: 'fmiranda@akbalsc.com',2123 currency: 'pesos',2124 building: result.buildings[3]2125 })2126 .then(function (customer) {2127 result.customers[3].push(customer);2128 return result;2129 });2130 })2131 .then(function (result) {2132 return Customer.create({2133 name: 'GANASVARO, S. DE R.L. DE C.V.',2134 tradename: 'GANASVARO, S. DE R.L. DE C.V.',2135 rfc: 'GAN120904E64',2136 address: 'Doctor Balmis No. 223-B',2137 neiborhood: 'Doctores Deleg. Cuauhtemoc',2138 zipCode: '06720',2139 city: 'Mexico',2140 state: 'D.F.',2141 country: 'Mexico',2142 representative: 'Miriam Cabrera Ronzon',2143 email: 'fmiranda@akbalsc.com',2144 currency: 'pesos',2145 building: result.buildings[3]2146 })2147 .then(function (customer) {2148 result.customers[3].push(customer);2149 return result;2150 });2151 })2152 .then(function (result) {2153 return Customer.create({2154 name: 'ADRIAN HUMBERTO DIAZ VILLALOBOS',2155 tradename: 'ADRIAN HUMBERTO DIAZ VILLALOBOS',2156 rfc: 'XAXX010101000',2157 address: 'Simona Barba No. 5110-19',2158 neiborhood: 'Partido Escobedo',2159 zipCode: '32330',2160 city: 'Juarez',2161 state: 'Chihuahua',2162 country: 'Mexico',2163 representative: 'Representante Legal',2164 email: 'fmiranda@akbalsc.com',2165 currency: 'pesos',2166 building: result.buildings[3]2167 })2168 .then(function (customer) {2169 result.customers[3].push(customer);2170 return result;2171 });2172 })2173 .then(function (result) {2174 return Customer.create({2175 name: 'CORPUS FACTURACION, S.A. DE C.V.',2176 tradename: 'CORPUS FACTURACION, S.A. DE C.V.',2177 rfc: 'CFA110411FW5',2178 address: 'Av. Heroico Colegio Militar No. 4709-2',2179 neiborhood: 'Nombre De Dios',2180 zipCode: '31105',2181 city: 'Chihuahua',2182 state: 'Chihuahua',2183 country: 'Mexico',2184 representative: 'Jose Roberto Silva Avila',2185 email: 'fmiranda@akbalsc.com',2186 currency: 'pesos',2187 building: result.buildings[3]2188 })2189 .then(function (customer) {2190 result.customers[3].push(customer);2191 return result;2192 });2193 })2194 .then(function (result) {2195 return Customer.create({2196 name: 'GENERAL NETWORKS, S.A. DE C.V.',2197 tradename: 'GENERAL NETWORKS, S.A. DE C.V.',2198 rfc: 'GNE140527223',2199 address: 'Villas Del Sirio No. 5822',2200 neiborhood: 'Cordilleras',2201 zipCode: '31124',2202 city: 'Chihuahua',2203 state: 'Chihuahua',2204 country: 'Mexico',2205 representative: 'Fidel Antonio Soto Reyes',2206 email: 'fmiranda@akbalsc.com',2207 currency: 'pesos',2208 building: result.buildings[3]2209 })2210 .then(function (customer) {2211 result.customers[3].push(customer);2212 return result;2213 });2214 })2215 .then(function (result) {2216 return Customer.create({2217 name: 'WITTMAN BATTENFELD MEXICO, S.A. DE C.V.',2218 tradename: 'WITTMAN BATTENFELD MEXICO, S.A. DE C.V.',2219 rfc: 'WBM0011144W7',2220 address: 'Rafael Sesma Huerta No. 21',2221 neiborhood: 'Parque Industrial Finsa',2222 zipCode: '76246',2223 city: 'Queretaro',2224 state: 'Queretaro',2225 country: 'Mexico',2226 representative: '',2227 email: 'fmiranda@akbalsc.com',2228 currency: 'pesos',2229 building: result.buildings[3]2230 })2231 .then(function (customer) {2232 result.customers[3].push(customer);2233 return result;2234 });2235 })2236 .then(function (result) {2237 return Customer.create({2238 name: 'SINDICATO DE TRABAJADORES AL SERVICIO DEL GOBIERNO DEL ESTADO',2239 tradename: 'SINDICATO DE TRABAJADORES AL SERVICIO DEL GOBIERNO DEL ESTADO',2240 rfc: 'STS870411JS2',2241 address: 'Av. Teofilo Borunda No. 2122',2242 neiborhood: 'Centro',2243 zipCode: '',2244 city: 'Chihuahua',2245 state: 'Chihuahua',2246 country: 'Mexico',2247 representative: 'Bernardina Garcia Murillo',2248 email: 'fmiranda@akbalsc.com',2249 currency: 'pesos',2250 building: result.buildings[3]2251 })2252 .then(function (customer) {2253 result.customers[3].push(customer);2254 return result;2255 });2256 })2257 .then(function (result) {2258 return Customer.create({2259 name: 'LAURA KARINA URIBE FENTANES',2260 tradename: 'LAURA KARINA URIBE FENTANES',2261 rfc: 'UIFL751217U79',2262 address: 'Simona Barba No. 5110-28',2263 neiborhood: 'Partido Escobedo',2264 zipCode: '32330',2265 city: 'Juarez',2266 state: 'Chihuahua',2267 country: 'Mexico',2268 representative: 'Laura Karina Uribe Fentanes',2269 email: 'fmiranda@akbalsc.com',2270 currency: 'pesos',2271 building: result.buildings[3]2272 })2273 .then(function (customer) {2274 result.customers[3].push(customer);2275 return result;2276 });2277 })2278 .then(function (result) {2279 return Customer.create({2280 name: 'AXTEL, S.A.B. DE C.V.',2281 tradename: 'AXTEL, S.A.B. DE C.V.',2282 rfc: 'AXT940727FP8',2283 address: 'Blvd. Gustavo DÃaz Ordaz Km. 3.33 L-1',2284 neiborhood: 'Unidad San Pedro',2285 zipCode: '66215',2286 city: 'San Pedro Garza',2287 state: 'Nuevo Leon',2288 country: 'Mexico',2289 representative: 'Aldo Lecanda Beckmann',2290 email: 'fmiranda@akbalsc.com',2291 currency: 'pesos',2292 building: result.buildings[3]2293 })2294 .then(function (customer) {2295 result.customers[3].push(customer);2296 return result;2297 });2298 })2299 .then(function (result) {2300 return Customer.create({2301 name: 'LETICIA GARCIA RODRIGUEZ',2302 tradename: 'LETICIA GARCIA RODRIGUEZ',2303 rfc: 'GARL530602G56',2304 address: 'Simona Barba No. 5525 L-4',2305 neiborhood: 'Partido Las Fuentes',2306 zipCode: '32370',2307 city: 'Juarez',2308 state: 'Chihuahua',2309 country: 'Mexico',2310 representative: 'Leticia Garcia Rodriguez',2311 email: 'fmiranda@akbalsc.com',2312 currency: 'pesos',2313 building: result.buildings[3]2314 })2315 .then(function (customer) {2316 result.customers[3].push(customer);2317 return result;2318 });2319 })2320 .then(function (result) {2321 return Customer.create({2322 name: 'IMPULSO EMPRESARIAL DE JUAREZ, S.A. DE C.V.',2323 tradename: 'IMPULSO EMPRESARIAL DE JUAREZ, S.A. DE C.V.',2324 rfc: 'IEJ0807243X4',2325 address: 'Simona Barba No. 5110-17',2326 neiborhood: 'San Angel',2327 zipCode: '32328',2328 city: 'Juarez',2329 state: 'Chihuahua',2330 country: 'Mexico',2331 representative: 'Enrique Martinez Joo',2332 email: 'fmiranda@akbalsc.com',2333 currency: 'pesos',2334 building: result.buildings[3]2335 })2336 .then(function (customer) {2337 result.customers[3].push(customer);2338 return result;2339 });2340 })2341 .then(function (result) {2342 return Customer.create({2343 name: 'MARIA DE LOS ANGELES SALAS CEPEDA',2344 tradename: 'MARIA DE LOS ANGELES SALAS CEPEDA',2345 rfc: 'SACA750101I9A',2346 address: 'Simona Barba No. 5110-34',2347 neiborhood: 'Partido Escobedo',2348 zipCode: '32330',2349 city: 'Juarez',2350 state: 'Chihuahua',2351 country: 'Mexico',2352 representative: 'Maria De Los Angeles Salas Cepeda',2353 email: 'fmiranda@akbalsc.com',2354 currency: 'dolares',2355 building: result.buildings[3]2356 })2357 .then(function (customer) {2358 result.customers[3].push(customer);2359 return result;2360 });2361 })2362 .then(function (result) {2363 return Customer.create({2364 name: 'SISTEMAS DE INTEGRACIÃN ADMINISTRATIVA S.A DE C.V.',2365 tradename: 'SISTEMAS DE INTEGRACIÃN ADMINISTRATIVA S.A DE C.V.',2366 rfc: 'SIA0404025R3',2367 address: 'Simona Barba No. 5110-35',2368 neiborhood: 'Partido Escobedo',2369 zipCode: '32330',2370 city: 'Juarez',2371 state: 'Chihuahua',2372 country: 'Mexico',2373 representative: 'Abel Peña Rodriguez',2374 email: 'fmiranda@akbalsc.com',2375 currency: 'dolares',2376 building: result.buildings[3]2377 })2378 .then(function (customer) {2379 result.customers[3].push(customer);2380 return result;2381 });2382 })2383 .then(function (result) {2384 return Customer.create({2385 name: 'TRANSPORTES GAMER, S.A. DE C.V.',2386 tradename: 'TRANSPORTES GAMER, S.A. DE C.V.',2387 rfc: 'TGA131106AV6',2388 address: 'Simona Barba No. 5110-39',2389 neiborhood: 'Partido Escobedo',2390 zipCode: '32330',2391 city: 'Juarez',2392 state: 'Chihuahua',2393 country: 'Mexico',2394 representative: '',2395 email: 'fmiranda@akbalsc.com',2396 currency: 'dolares',2397 building: result.buildings[3]2398 })2399 .then(function (customer) {2400 result.customers[3].push(customer);2401 return result;2402 });2403 })2404 .then(function (result) {2405 var building = result.buildings[3];2406 var units = result.units[3];2407 var customers = result.customers[3];2408 units.forEach(function (unit) {2409 building.units.push(unit);2410 })2411 customers.forEach(function (customer) {2412 building.customers.push(customer);2413 })2414 return Building.findById(building._id).exec()2415 .then(function (data) {2416 var updated = _.merge(data, building);2417 result.updated = updated;2418 return result;2419 });2420 })2421 .then(function (result) {2422 var updated = result.updated;2423 return updated.save().then(function () {2424 result.buildings[3] = updated;2425 return result;2426 });2427 })2428 .then(function (result) {2429 return Unit.create({2430 local: 1,2431 surface: 8,2432 type: 'Comercial',2433 description: '',2434 ocupated: false,2435 building: result.buildings[4]2436 })2437 .then(function (unit) {2438 result.units.push([unit]);2439 return result;2440 });2441 })2442 .then(function (result) {2443 return Unit.create({2444 local: 2,2445 surface: 8,2446 type: 'Comercial',2447 description: '',2448 ocupated: false,2449 building: result.buildings[4]2450 })2451 .then(function (unit) {2452 result.units[4].push(unit);2453 return result;2454 });2455 })2456 .then(function (result) {2457 return Unit.create({2458 local: 3,2459 surface: 8,2460 type: 'Comercial',2461 description: '',2462 ocupated: false,2463 building: result.buildings[4]2464 })2465 .then(function (unit) {2466 result.units[4].push(unit);2467 return result;2468 });2469 })2470 .then(function (result) {2471 return Unit.create({2472 local: 5,2473 surface: 8,2474 type: 'Comercial',2475 description: '',2476 ocupated: false,2477 building: result.buildings[4]2478 })2479 .then(function (unit) {2480 result.units[4].push(unit);2481 return result;2482 });2483 })2484 .then(function (result) {2485 return Unit.create({2486 local: 6,2487 surface: 8,2488 type: 'Comercial',2489 description: '',2490 ocupated: false,2491 building: result.buildings[4]2492 })2493 .then(function (unit) {2494 result.units[4].push(unit);2495 return result;2496 });2497 })2498 .then(function (result) {2499 return Unit.create({2500 local: 7,2501 surface: 8,2502 type: 'Comercial',2503 description: '',2504 ocupated: false,2505 building: result.buildings[4]2506 })2507 .then(function (unit) {2508 result.units[4].push(unit);2509 return result;2510 });2511 })2512 .then(function (result) {2513 return Unit.create({2514 local: 8,2515 surface: 8,2516 type: 'Comercial',2517 description: '',2518 ocupated: false,2519 building: result.buildings[4]2520 })2521 .then(function (unit) {2522 result.units[4].push(unit);2523 return result;2524 });2525 })2526 .then(function (result) {2527 return Unit.create({2528 local: 9,2529 surface: 8,2530 type: 'Comercial',2531 description: '',2532 ocupated: false,2533 building: result.buildings[4]2534 })2535 .then(function (unit) {2536 result.units[4].push(unit);2537 return result;2538 });2539 })2540 .then(function (result) {2541 return Customer.create({2542 name: 'CONSULTORIA AKBAL, S.C.',2543 tradename: 'CONSULTORIA AKBAL, S.C.',2544 rfc: 'CAK971001JU8',2545 address: 'Simona Barba No. 5110-18',2546 neiborhood: 'Partido Escobedo',2547 zipCode: '32330',2548 city: 'Juarez',2549 state: 'Chihuahua',2550 country: 'Mexico',2551 representative: 'Mario Cepeda Lucero',2552 email: 'fmiranda@akbalsc.com',2553 currency: 'dolares',2554 building: result.buildings[4]2555 })2556 .then(function (customer) {2557 result.customers.push([customer]);2558 return result;2559 });2560 })2561 .then(function (result) {2562 return Customer.create({2563 name: 'SOLUCIONES ADMINISTRATIVAS SAID',2564 tradename: 'SOLUCIONES ADMINISTRATIVAS SAID',2565 rfc: 'XAXX010101000',2566 address: 'Simona Barba No. 5110-19',2567 neiborhood: 'Partido Escobedo',2568 zipCode: '32330',2569 city: 'Juarez',2570 state: 'Chihuahua',2571 country: 'Mexico',2572 representative: 'Representante Legal',2573 email: 'fmiranda@akbalsc.com',2574 currency: 'dolares',2575 building: result.buildings[4]2576 })2577 .then(function (customer) {2578 result.customers[4].push(customer);2579 return result;2580 });2581 })2582 .then(function (result) {2583 return Customer.create({2584 name: 'CONSORCIO GALLO DE MÃXICO S DE RL DE CV',2585 tradename: 'CONSORCIO GALLO DE MÃXICO S DE RL DE CV',2586 rfc: 'CGM110824239',2587 address: 'Calle 18 No. 1811',2588 neiborhood: 'Zona Centro',2589 zipCode: '32330',2590 city: 'Matamoros',2591 state: 'Tamaulipas',2592 country: 'Mexico',2593 representative: 'Lic. Susana Espinoza',2594 email: 'fmiranda@akbalsc.com',2595 currency: 'dolares',2596 building: result.buildings[4]2597 })2598 .then(function (customer) {2599 result.customers[4].push(customer);2600 return result;2601 });2602 })2603 .then(function (result) {2604 return Customer.create({2605 name: 'ADRIAN HUMBERTO DIAZ VILLALOBOS',2606 tradename: 'ADRIAN HUMBERTO DIAZ VILLALOBOS',2607 rfc: 'XAXX010101000',2608 address: 'Simona Barba No. 5110-19',2609 neiborhood: 'Partido Escobedo',2610 zipCode: '32330',2611 city: 'Juarez',2612 state: 'Chihuahua',2613 country: 'Mexico',2614 representative: 'Representante Legal',2615 email: 'fmiranda@akbalsc.com',2616 currency: 'dolares',2617 building: result.buildings[4]2618 })2619 .then(function (customer) {2620 result.customers[4].push(customer);2621 return result;2622 });2623 })2624 .then(function (result) {2625 return Customer.create({2626 name: 'DEUTSCHE BANK MEXICO SA IBM DIVISION FIDUCIARIA F/1616',2627 tradename: 'DEUTSCHE BANK MEXICO SA IBM DIVISION FIDUCIARIA F/1616',2628 rfc: 'DBM121023M10',2629 address: 'Ricardo Margain Zozaya No. 605',2630 neiborhood: 'Santa Engracia',2631 zipCode: '66267',2632 city: 'San Pedro Garza',2633 state: 'Nuevo Leon',2634 country: 'Mexico',2635 representative: 'C.P. Deyanira Herrera Nava',2636 email: 'fmiranda@akbalsc.com',2637 currency: 'dolares',2638 building: result.buildings[4]2639 })2640 .then(function (customer) {2641 result.customers[4].push(customer);2642 return result;2643 });2644 })2645 .then(function (result) {2646 return Customer.create({2647 name: 'GARRAT CALLAHAN INTERNATIONAL, S. DE R.L. DE C.V.',2648 tradename: 'GARRAT CALLAHAN INTERNATIONAL, S. DE R.L. DE C.V.',2649 rfc: 'GCI0304021Y8',2650 address: 'Dia Del Telefonista No. 1132',2651 neiborhood: 'Sauzal',2652 zipCode: '32700',2653 city: 'Juarez',2654 state: 'Chihuahua',2655 country: 'Mexico',2656 representative: 'Mario Cepeda Lucero',2657 email: 'fmiranda@akbalsc.com',2658 currency: 'dolares',2659 building: result.buildings[4]2660 })2661 .then(function (customer) {2662 result.customers[4].push(customer);2663 return result;2664 });2665 })2666 .then(function (result) {2667 return Customer.create({2668 name: 'THE WATER INITIATIVE OF MEXICO, S. DE R.L. DE C.V.',2669 tradename: 'THE WATER INITIATIVE OF MEXICO, S. DE R.L. DE C.V.',2670 rfc: 'WIM0806026P1',2671 address: 'Simona Barba No. 5110-19',2672 neiborhood: 'Los Colorines',2673 zipCode: '32380',2674 city: 'Juarez',2675 state: 'Chihuahua',2676 country: 'Mexico',2677 representative: 'Mario Cepeda Lucero',2678 email: 'fmiranda@akbalsc.com',2679 currency: 'dolares',2680 building: result.buildings[4]2681 })2682 .then(function (customer) {2683 result.customers[4].push(customer);2684 return result;2685 });2686 })2687 .then(function (result) {2688 var building = result.buildings[4];2689 var units = result.units[4];2690 var customers = result.customers[4];2691 units.forEach(function (unit) {2692 building.units.push(unit);2693 })2694 customers.forEach(function (customer) {2695 building.customers.push(customer);2696 })2697 return Building.findById(building._id).exec()2698 .then(function (data) {2699 var updated = _.merge(data, building);2700 result.updated = updated;2701 return result;2702 });2703 })2704 .then(function (result) {2705 var updated = result.updated;2706 return updated.save().then(function () {2707 result.buildings[4] = updated;2708 return result;2709 });2710 })2711 .then(function (result) {2712 //result.units = [];2713 //console.log(result.units[0]);2714 console.log('finished clean and populating MongoDB');2715 }, function(err) {2716 // want to handle errors here2717 console.log(err);2718 });2719// Company.find({}).remove(function() {2720// Company.create({2721// name: 'Inmobiliaria Celu',2722// }, function() {2723// console.log('remove company');ahorita te2724// });2725// });2726// Building.find({}).remove(function() {2727// console.log('remove building');2728// });2729ExchangeRate.find({}).remove(function() {2730 ExchangeRate.create({2731 date : new Date(2016,1,2),2732 value : 18.1935002733 }, {2734 date : new Date(2016,1,3),2735 value : 18.4902002736 }, {2737 date : new Date(2016,1,4),2738 value : 18.4537002739 }, {2740 date : new Date(2016,1,5),2741 value : 18.1891002742 }, {2743 date : new Date(2016,1,8),2744 value : 18.3748002745 }, {2746 date : new Date(2016,1,9),2747 value : 18.6959002748 }, {2749 date : new Date(2016,1,10),2750 value : 18.7818002751 }, {2752 date : new Date(2016,1,11),2753 value : 18.8089002754 }, {2755 date : new Date(2016,1,12),2756 value : 19.1754002757 }, {2758 date : new Date(2016,1,15),2759 value : 19.0392002760 }, {2761 date : new Date(2016,1,16),2762 value : 18.8471002763 }, {2764 date : new Date(2016,1,17),2765 value : 18.8148002766 }, {2767 date : new Date(2016,1,18),2768 value : 18.3895002769 }, {2770 date : new Date(2016,1,19),2771 value : 18.1439002772 }, {2773 date : new Date(2016,1,22),2774 value : 18.2762002775 }, {2776 date : new Date(2016,1,16),2777 value : 18.1935002778 }, {2779 date : new Date(2016,1,22),2780 value : 18.1935002781 }, {2782 date : new Date(2016,1,23),2783 value : 18.0568002784 }, {2785 date : new Date(2016,1,24),2786 value : 18.1948002787 }, {2788 date : new Date(2016,1,25),2789 value : 18.2893002790 }, {2791 date : new Date(2016,1,26),2792 value : 18.1680002793 });2794});2795Unit.find({}).remove();2796Customer.find({}).remove();...
moments.spec.js
Source:moments.spec.js
1'use strict';2var _ = require('underscore');3var juttle_test_utils = require('../specs/juttle-test-utils');4var check_juttle = juttle_test_utils.check_juttle;5var expect = require('chai').expect;6var parser = require('../../../lib/parser');7describe('Juttle Moments tests', function() {8 it('distinguishes between value and duration for parameters', function() {9 return parser.parse('emit -from :now: -for :00:00:10: -hz 1 | view result')10 .then(function(ast) {11 expect(ast.elements[0].elements[0].options[0].expr.type).to.equal('MomentLiteral');12 expect(ast.elements[0].elements[0].options[1].expr.type).to.equal('DurationLiteral');13 });14 });15 it('parses moment in proc call', function() {16 return parser.parse('sub testProc(m) {'17 +'emit -from m -hz 1000 -limit 10'18 +'}'19 +'testProc -m :now: | view result');20 });21 it('parses moment in const assignment', function() {22 return parser.parse('const m = :now:;'23 +'emit | view result');24 });25 it('parses moment in variable assignment', function() {26 return parser.parse('function f() {var m = :now:;}'27 +'emit | view result');28 });29 it('parses moment in function call', function() {30 return parser.parse('const m;'31 +'function testFunction(_m) {'32 +'m = _m;'33 +'}'34 +'testFunction -m :now: | view result');35 });36 it('parses moment in filter equality expression', function() {37 return parser.parse('read test | filter time = :now: | view result');38 });39 it('parses moment in filter inequality expression', function() {40 return parser.parse('read test | filter time > :now: | view result');41 });42 it('runs moment in filter inequality expression', function() {43 return check_juttle({44 program: 'const start = :now: - :2 seconds:; emit -from start -hz 1000 -limit 10 | filter time < :now: | view result'45 })46 .then(function(res) {47 expect(res.sinks.result.length).to.equal(10);48 });49 });50 it('parses moment in put expression', function() {51 return parser.parse('read test | put foo = :now: | view result');52 });53 it('runs moment in put expression', function() {54 var now = new Date();55 var ts = now.getTime();56 return check_juttle({57 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :'+ now.toISOString() +': | view result'58 })59 .then(function(res) {60 expect(res.sinks.result.length).to.equal(10);61 _(res.sinks.result).each(function(point) {62 expect(new Date(point.foo).getTime()).to.equal(ts);63 });64 });65 });66 // Moment Addition67 it('moment + moment -> **ILLEGAL**', function() {68 var now = new Date();69 return check_juttle({70 program: 'function f(x) { return :'+ now.toISOString() +': + :'+ now.toISOString() +':;}' +71 'emit -from :now: -hz 1000 -limit 1 | put foo = f(x) | view result'72 })73 .then(function(res) {74 expect(res.warnings).to.have.length(1);75 });76 });77 it('moment + duration -> moment', function() {78 var now = new Date();79 return check_juttle({80 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :'+ now.toISOString() +': + : 00:10:00 : | view result'81 })82 .then(function(res) {83 expect(res.sinks.result.length).to.equal(10);84 _(res.sinks.result).each(function(point) {85 expect(new Date(point.foo).getTime()).to.equal(now.getTime() + 600000);86 });87 });88 });89 it('duration + moment -> moment', function() {90 var now = new Date();91 return check_juttle({92 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:10:00: + :'+ now.toISOString() +': | view result'93 })94 .then(function(res) {95 expect(res.sinks.result.length).to.equal(10);96 _(res.sinks.result).each(function(point) {97 expect(new Date(point.foo).getTime()).to.equal(now.getTime() + 600000);98 });99 });100 });101 it('duration + duration -> duration', function() {102 return check_juttle({103 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:10:00: + :00:00:30.123: | view result'104 })105 .then(function(res) {106 expect(res.sinks.result.length).to.equal(10);107 _(res.sinks.result).each(function(point) {108 expect(point.foo).to.equal('00:10:30.123');109 });110 });111 });112 // Moment Subtraction113 it('moment - moment -> duration (positive)', function() {114 return check_juttle({115 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :2014-09-08T18:30:00.000Z: - :2014-09-08T18:00:00.000Z: | view result'116 })117 .then(function(res) {118 expect(res.sinks.result.length).to.equal(10);119 _(res.sinks.result).each(function(point) {120 expect(point.foo).to.equal('00:30:00.000');121 });122 });123 });124 it('moment - moment -> duration (negative)', function() {125 return check_juttle({126 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :2014-09-08T18:00:00.000Z: - :2014-09-08T18:30:00.000Z: | view result'127 })128 .then(function(res) {129 expect(res.sinks.result.length).to.equal(10);130 _(res.sinks.result).each(function(point) {131 expect(point.foo).to.equal('-00:30:00.000');132 });133 });134 });135 it('moment - duration -> moment', function() {136 return check_juttle({137 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :2014-09-08T18:30:00.000Z: - :00:10:00: | view result'138 })139 .then(function(res) {140 expect(res.sinks.result.length).to.equal(10);141 _(res.sinks.result).each(function(point) {142 expect(new Date(point.foo).getTime()).to.equal(new Date('2014-09-08T18:30:00.000Z').getTime() - 600000);143 });144 });145 });146 it('duration - moment -> **ILLEGAL**', function() {147 return check_juttle({148 program: 'function f(x) { return :00:10:00: - :2014-09-08T18:30:00.000Z:;} ' +149 'emit -from :now: -hz 1000 -limit 1 | put foo = f(x) | view result'150 })151 .then(function(res) {152 expect(res.warnings).to.have.length(1);153 });154 });155 it('duration - duration -> duration (positive)', function() {156 return check_juttle({157 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:10:00: - :00:05:00: | view result'158 })159 .then(function(res) {160 expect(res.sinks.result.length).to.equal(10);161 _(res.sinks.result).each(function(point) {162 expect(point.foo).to.equal('00:05:00.000');163 });164 });165 });166 it('duration - duration -> duration (negative)', function() {167 return check_juttle({168 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:05:00: - :00:10:00: | view result'169 })170 .then(function(res) {171 expect(res.sinks.result.length).to.equal(10);172 _(res.sinks.result).each(function(point) {173 expect(point.foo).to.equal('-00:05:00.000');174 });175 });176 });177 it('number * duration -> duration', function() {178 return check_juttle({179 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = 5 * :00:00:05: | view result'180 })181 .then(function(res) {182 expect(res.sinks.result.length).to.equal(10);183 _(res.sinks.result).each(function(point) {184 expect(point.foo).to.equal('00:00:25.000');185 });186 });187 });188 it('duration * number -> duration', function() {189 return check_juttle({190 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:00:05: * 5 | view result'191 })192 .then(function(res) {193 expect(res.sinks.result.length).to.equal(10);194 _(res.sinks.result).each(function(point) {195 expect(point.foo).to.equal('00:00:25.000');196 });197 });198 });199 it('duration / duration -> number', function() {200 return check_juttle({201 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:00:05: / :00:00:05: | view result'202 })203 .then(function(res) {204 expect(res.sinks.result.length).to.equal(10);205 _(res.sinks.result).each(function(point) {206 expect(point.foo).to.equal(1);207 });208 });209 });210 it('duration / number -> duration', function() {211 return check_juttle({212 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:00:05: / 5 | view result'213 })214 .then(function(res) {215 expect(res.sinks.result.length).to.equal(10);216 _(res.sinks.result).each(function(point) {217 expect(point.foo).to.equal('00:00:01.000');218 });219 });220 });221 it('duration % duration -> duration', function() {222 return check_juttle({223 program: 'emit -from :now: -hz 1000 -limit 10 | put foo = :00:00:05.123: % :00:00:05: | view result'224 })225 .then(function(res) {226 expect(res.sinks.result.length).to.equal(10);227 _(res.sinks.result).each(function(point) {228 expect(point.foo).to.equal('00:00:00.123');229 });230 });231 });232 // special moment and duration functions via momentjs233 it('Date.startOf("day")', function() {234 return check_juttle({235 program: 'emit -hz 1000 -limit 1 | put today = Date.startOf(:2014-01-01T13:45:00Z:, "day") | view result'236 })237 .then(function(res) {238 expect(res.sinks.result[0].today).to.equal('2014-01-01T00:00:00.000Z');239 });240 });241 it('Date.endOf("day")', function() {242 return check_juttle({243 program: 'emit -hz 1000 -limit 1 | put eom = Date.endOf(:2014-01-01T13:45:00Z:, "month") | view result'244 })245 .then(function(res) {246 expect(res.sinks.result[0].eom).to.equal('2014-01-31T23:59:59.999Z');247 });248 });249 it('date.unix', function() {250 return check_juttle({251 program: 'emit -hz 1000 -limit 1 | put zero = Date.unix(Date.new(0)), hunnerd = Date.unix(Date.new(100)) | view result'252 })253 .then(function(res) {254 expect(res.sinks.result[0].zero).to.equal(0);255 expect(res.sinks.result[0].hunnerd).to.equal(100);256 });257 });258 it('date.elapsed', function() {259 return check_juttle({260 program: 'const start=:now: - Duration.new(60) ; emit -hz 100 -limit 2 | put delta = Date.elapsed(start) | view result'261 })262 .then(function(res) {263 expect(res.sinks.result[1].delta).gt(60);264 expect(res.sinks.result[1].delta).lt(70);265 });266 });267 it('moment.format, default', function() {268 return check_juttle({269 program: 'emit -hz 1000 -limit 1 | put foo=Date.format(:2014-01-01:), len=String.length(#foo) | view result'270 })271 .then(function(res) {272 expect(res.sinks.result[0].len).to.equal(24);273 });274 });275 it('moment.format, with format', function() {276 return check_juttle({277 program: 'emit -hz 1000 -limit 1 | put foo=Date.format(:2014-01-01:, "MMMM D0, YYYY") | view result'278 })279 .then(function(res) {280 expect(res.sinks.result[0].foo).to.equal('January 10, 2014');281 });282 });283 it('moment.get', function() {284 return check_juttle({285 program: 'emit -hz 1000 -limit 1 | put dur=:2014-10-01:, ten=Date.get(dur, "month"), one=Date.get(dur, "day") | view result'286 })287 .then(function(res) {288 expect(res.sinks.result[0].ten).to.equal(10);289 expect(res.sinks.result[0].one).to.equal(1);290 });291 });292 it('duration.get', function() {293 return check_juttle({294 program: 'emit -hz 1000 -limit 1 | put dur=:8 days:+:09:10:11.123:, ten=Duration.get(dur, "minutes"), eight=Duration.get(dur, "days") | view result'295 })296 .then(function(res) {297 expect(res.sinks.result[0].ten).to.equal(10);298 expect(res.sinks.result[0].eight).to.equal(8);299 });300 });301 it('duration.as.seconds', function() {302 return check_juttle({303 program: 'emit -hz 1000 -limit 1 | put secs=Duration.as(:09:10:11.123:, "seconds") | view result'304 })305 .then(function(res) {306 expect(res.sinks.result[0].secs).to.equal(33011.123);307 });308 });309 // Programmatic Dates/Durations310 it('Date.new(5)', function() {311 return check_juttle({312 program: 'emit -limit 1 | put foo = Date.new(5) | view result'313 })314 .then(function(res) {315 expect(new Date(res.sinks.result[0].foo).getTime()).to.equal(5000);316 });317 });318 it('fails Date.new("blah")', function() {319 return check_juttle({320 program: 'emit -from :now: -hz 1000 -limit 1 | put foo = Date.new("blah") | view result'321 })322 .then(function(res) {323 expect(res.warnings[0]).to.equal('Unable to parse date: "blah"');324 })325 .catch(function(err) {326 expect(err.message).equal('Unable to parse date: "blah"');327 });328 });329 it('Duration.new(5)', function() {330 return check_juttle({331 program: 'emit -limit 1 | put foo = Duration.new(5) | view result'332 })333 .then(function(res) {334 expect(res.sinks.result[0].foo).to.equal('00:00:05.000');335 });336 });337 it('fails Duration.new("blah")', function() {338 return check_juttle({339 program: 'emit -from :now: -hz 1000 -limit 1 | put foo = Duration.new("blah") | view result'340 })341 .then(function(res) {342 expect(res.errors[0]).to.equal('Unable to parse as formatted duration: blah');343 })344 .catch(function(err) {345 expect(err.message).equal('Unable to parse as formatted duration: blah');346 });347 });348 it('Date.quantize(Date.now(), Duration.new(5))', function() {349 return check_juttle({350 program: 'emit -from :now: -hz 1000 -limit 1 | put foo = Date.quantize(Date.time(), Duration.new(5)) | view result'351 })352 .then(function(res) {353 expect(res.errors).to.have.length(0);354 });355 });356 it('fails Date.quantize(Date.now(), 5)', function() {357 return check_juttle({358 program: 'emit -from :now: -hz 1000 -limit 1 | put foo = Date.quantize(Date.time(), 5) | view result'359 })360 .then(function(res) {361 expect(res.warnings[0]).to.equal('Invalid argument type for \"Date.quantize\": expected duration, received number (5).');362 });363 });364 it('parse errors are caught at parse time', function() {365 return check_juttle({366 program: 'emit -limit 1 | put moment=:1 day ago and 1 day ago: | view table'367 })368 .then(function(res) {369 throw new Error('should have failed');370 })371 .catch(function(err) {372 expect(err.name).equal('SyntaxError');373 });374 });...
app.js
Source:app.js
1var prompt = require("prompt")2var Packs = require("3vot-cloud/utils/packs")3var Download = require("3vot-cloud/app/download")4var Upload = require("3vot-cloud/app/upload")5var Build = require("3vot-cloud/app/build")6var Log = require("3vot-cloud/utils/log")7var Path = require("path")8var Stats = require("3vot-cloud/utils/stats")9var WalkDir = require("3vot-cloud/utils/walk")10var Transform = require("../app/utils/transform")11var fs = require("fs")12var eco = require("eco")13var open = require("open");14function download(){15 var prompts = [16 { name: 'app_name', description: 'App Name ( The name of the app you want to download)' },17 { name: 'app_user_name', description: 'Profile: ( The profile name of the owner of the app )' }, 18 { name: 'app_version', description: 'Version: ( The App version) hit enter for latest )' },19 { name: 'app_new_name', description: 'Name: ( What you want to name your app ) *enter for same' },20 ]21 prompt.get(prompts, onResult);22 function onResult(err, result) {23 Log.info("<:> 3VOT DIGITAL CONTENT CLOUD :=)")24 25 Packs._3vot(result, false)26 .then( function(res){ result = res; return Download(result); } )27 .then( function(){ Log.info("3. Preview with '3vot server'"); Log.info("ok"); } )28 .then( function(){ 29 return Stats.track("app:download", result ) 30 })31 .then(function(){ process.exit() })32 .fail( function(err){ Log.error(err, "./bin/app", 52 ); });33 };34}35function create(){36 var prompts = [ { name: 'app_new_name', description: 'Name: ( The name of your new app )' } ];37 38 prompt.start();39 prompt.get(prompts, onResult);40 function onResult(err, result) {41 result.app_user_name = "start"42 result.app_name = "blank";43 Log.info("<:> 3VOT DIGITAL CONTENT CLOUD :=)")44 Packs._3vot(result, false)45 .then( function(res){ result = res; return Download(result); } )46 .then( function(){ Log.info("ok"); } )47 .then( function(){ return Stats.track("app:template", result ) } )48 .then(function(){ process.exit() })49 .fail( function(err){ Log.error(err, "./prompt/app", 8273 ); }); 50 };51}52function publish(ignoreSource){53 if(!ignoreSource) ignoreSource = false;54 var prompts = [ 55 { name: 'app_version', description: 'Version: ( The Version of the App you want to publish, enter for latest )' } 56 ]57 58 prompt.get(prompts, onResult);59 function onResult(err, result) {60 Log.info("<:> 3VOT DIGITAL CONTENT CLOUD :=)")61 result.production = true;62 if(ignoreSource != false) result.uploadSource = false;63 Packs._3vot(result)64 .then( function(res){ 65 result = res; 66 result.transform = function(tempvars){67 transformToProduction(result,tempvars)68 }69 return Upload(result); } )70 .then( function(){71 var url = "http://" + result.package.threevot.paths.productionBucket + "/" + result.user.user_name + "/" + result.package.name 72 Log.info("App Available at: " + url)73 open(url);74 return Stats.track("app:publish", result ) 75 })76 .then(function(){ process.exit() })77 .fail( function(err){ Log.error(err, "./prompt/app",106 ); });78 }79}80function upload(ignoreSource){81 Packs._3vot({ ignoreSource: ignoreSource || false })82 .then( function(res){ 83 result = res; 84 result.transform = function(tempvars){85 transformToProduction(result,tempvars)86 }87 return Upload(result); } )88 .then( function(app){ 89 var url = "http://" + result.package.threevot.paths.productionBucket + "/" + result.user.user_name + "/" + result.package.name + "_" + app.version90 Log.info("App Available at: " + url)91 open(url);92 return Stats.track("app:upload", result ) 93 })94 .then(function(){ process.exit() })95 .fail( function(err){ Log.error(err, "./prompt/app",123 ); });96}97function build(production){98 Log.info("<:> 3VOT DIGITAL CONTENT CLOUD :=)")99 var result = {}100 if(production) result.transform = function(tempvars){ transformToProduction(result,tempvars) }101 Packs._3vot(result, false)102 .then( function(res){ result = res; return Build(result); } )103 .then( function(){ Log.info("ok"); } )104 .then( function(){ return Stats.track("app:build", result ) } )105 .then(function(){ process.exit() })106 .fail( function(err){ Log.error(err, "./prompt/app",136 ); });107}108function transformToProduction( result, tempvars ){109 var apps = WalkDir( Path.join( process.cwd(), result.package.threevot.distFolder ) );110 if(tempvars && tempvars.app) result.version = tempvars.app.version;111 apps.forEach( function(path){112 var body = Transform.readByType(path.path, "production", result )113 fs.writeFileSync(path.path,body);114 });115}116module.exports = {117 upload: upload,118 download: download,119 publish: publish,120 build: build,121 create: create...
Using AI Code Generation
1const expect = require('unexpected')2 .clone()3 .use(require('unexpected-promise'));4const myPromise = new Promise((resolve, reject) => {5 resolve('foo');6});7describe('myPromise', () => {8 it('should eventually be fulfilled with "foo"', () => {9 return expect(myPromise, 'to be fulfilled with', 'foo');10 });11});
Using AI Code Generation
1const expect = require('unexpected')2 .clone()3 .use(require('unexpected-promise'));4describe('some test', () => {5 it('should do something', () => {6 return expect(somePromise(), 'to be fulfilled with', 'some value');7 });8});
Using AI Code Generation
1const Promise = require('bluebird');2const expect = require('unexpected').clone().use(require('unexpected-promise'));3describe('test', () => {4 it('should pass', () => {5 return expect(Promise.resolve(1), 'to be fulfilled with', 1);6 });7});8const Promise = require('bluebird');9const expect = require('unexpected').clone().use(require('unexpected-check'));10describe('test', () => {11 it('should pass', () => {12 return expect(13 Promise.resolve(1),14 expect.it('to be a number')15 );16 });17});18const Promise = require('bluebird');19const expect = require('unexpected').clone().use(require('unexpected-sinon'));20describe('test', () => {21 it('should pass', () => {22 return expect(23 Promise.resolve(1),24 );25 });26});27const Promise = require('bluebird');28const expect = require('unexpected').clone().use(require('unexpected-messy'));29describe('test', () => {30 it('should pass', () => {31 return expect(32 Promise.resolve(1),33 );34 });35});36const Promise = require('bluebird');37const expect = require('unexpected').clone().use(require('unexpected-mitm'));38describe('test', () => {39 it('should pass', () => {40 return expect(41 Promise.resolve(1),42 );43 });44});
Using AI Code Generation
1var expect = require('unexpected')2 .clone()3 .use(require('unexpected-http'));4var http = require('http');5var server = http.createServer(function (req, res) {6 res.end('Hello, world!');7});8server.listen(1337);9server.close();10var expect = require('unexpected')11 .clone()12 .use(require('unexpected-http'));13var http = require('http');14var server = http.createServer(function (req, res) {15 res.end('Hello, world!');16});17server.listen(1337);18 .then(function (res) {19 console.log(res.body.toString());20 });21server.close();22var expect = require('unexpected')23 .clone()24 .use(require('unexpected-http'));25var http = require('http');26var server = http.createServer(function (req, res) {27 res.end('Hello, world!');28});29server.listen(1337);30 .then(function (res) {31 console.log(res.body.toString());32 });33server.close();34var expect = require('unexpected')35 .clone()36 .use(require('unexpected-http'));37var http = require('http');38var server = http.createServer(function (req, res) {39 res.end('Hello, world!');40});41server.listen(1337);42 .then(function (res) {43 console.log(res.body.toString());44 });45server.close();46var expect = require('unexpected')47 .clone()48 .use(require('unexpected-http'));49var http = require('http');50var server = http.createServer(function (req, res) {51 res.end('Hello, world!');52});53server.listen(1337);54 .then(function (res) {55 console.log(res.body.toString());56 });57server.close();
Using AI Code Generation
1const expect = require('unexpected')2 .clone()3 .use(require('unexpected-http'));4const http = require('http');5const url = require('url');6const fs = require('fs');7const server = http.createServer((req, res) => {8 const parsedUrl = url.parse(req.url, true);9 const { pathname } = parsedUrl;10 if (pathname === '/users') {11 { id: 1, name: 'John', age: 25 },12 { id: 2, name: 'Jane', age: 27 },13 ];14 res.writeHead(200, { 'Content-Type': 'application/json' });15 res.end(JSON.stringify(users));16 } else if (pathname === '/users/1') {17 const user = { id: 1, name: 'John', age: 25 };18 res.writeHead(200, { 'Content-Type': 'application/json' });19 res.end(JSON.stringify(user));20 } else if (pathname === '/users/2') {21 const user = { id: 2, name: 'Jane', age: 27 };22 res.writeHead(200, { 'Content-Type': 'application/json' });23 res.end(JSON.stringify(user));24 } else if (pathname === '/users/3') {25 res.writeHead(404, { 'Content-Type': 'application/json' });26 res.end(JSON.stringify({ error: 'User not found' }));27 } else if (pathname === '/users/4') {28 res.writeHead(400, { 'Content-Type': 'application/json' });29 res.end(JSON.stringify({ error: 'Invalid user id' }));30 } else if (pathname === '/users/5') {31 res.writeHead(500, { 'Content-Type': 'application/json' });32 res.end(JSON.stringify({ error: 'Internal server error' }));33 } else if (pathname === '/users/6') {34 res.writeHead(200, { 'Content-Type': 'application/json' });35 res.end(JSON.stringify(null));36 } else if (pathname === '/users/7') {37 res.writeHead(200, { 'Content-Type': 'application/json' });38 res.end(JSON.stringify(undefined));39 } else if (pathname === '/users/8') {40 res.writeHead(200, { 'Content-Type': 'application/json' });41 res.end(JSON.stringify(''));42 } else
Using AI Code Generation
1const expect = require('unexpected')2 .clone()3 .use(require('unexpected-sinon'))4 .use(require('unexpected-express'));5const expect = require('unexpected')6 .clone()7 .use(require('unexpected-sinon'))8 .use(require('unexpected-express'))9 .use(require('unexpected-http'));10const expect = require('unexpected')11 .clone()12 .use(require('unexpected-sinon'))13 .use(require('unexpected-express'))14 .use(require('unexpected-http'));15const expect = require('unexpected')16 .clone()17 .use(require('unexpected-sinon'))18 .use(require('unexpected-express'))19 .use(require('unexpected-http'));20const expect = require('unexpected')21 .clone()22 .use(require('unexpected-sinon'))23 .use(require('unexpected-express'))24 .use(require('unexpected-http'));25const expect = require('unexpected')26 .clone()27 .use(require('unexpected-sinon'))28 .use(require('unexpected-express'))29 .use(require('unexpected-http'));30const expect = require('unexpected')31 .clone()32 .use(require('unexpected-sinon'))33 .use(require('unexpected-express'))34 .use(require('unexpected-http'));35const expect = require('unexpected')36 .clone()37 .use(require('unexpected-sinon'))38 .use(require('unexpected-express'))39 .use(require('unexpected-http'));40const expect = require('unexpected')41 .clone()42 .use(require('unexpected-sinon'))43 .use(require('unexpected-express'))44 .use(require('unexpected-http'));45const expect = require('unexpected')46 .clone()47 .use(require('unexpected
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!