How to use readTables method in wpt

Best JavaScript code snippet using wpt

migrate.test.js

Source:migrate.test.js Github

copy

Full Screen

...63 describe(Support.getTestDialectTeaser(flag), () => {64 it('creates a SequelizeMeta table', function (done) {65 const self = this;66 prepare(() => {67 helpers.readTables(self.sequelize, (tables) => {68 expect(tables).to.have.length(2);69 expect(tables).to.contain('SequelizeMeta');70 done();71 });72 });73 });74 it('creates the respective table', function (done) {75 const self = this;76 prepare(() => {77 helpers.readTables(self.sequelize, (tables) => {78 expect(tables).to.have.length(2);79 expect(tables).to.contain('Person');80 done();81 });82 });83 });84 it('fails with a not 0 exit code', (done) => {85 prepare(done, {86 migrationFile: 'invalid/*createPerson',87 cli: { exitCode: 1 },88 });89 });90 describe('the logging option', () => {91 it('does not print sql queries by default', (done) => {92 prepare((__, stdout) => {93 expect(stdout).to.not.contain('Executing');94 done();95 });96 });97 it('interpretes a custom option', (done) => {98 prepare(99 (__, stdout) => {100 expect(stdout).to.contain('Executing');101 done();102 },103 { config: { logging: true } }104 );105 });106 });107 describe('promise based migrations', () => {108 it('correctly creates two tables', function (done) {109 const self = this;110 prepare(111 () => {112 helpers.readTables(self.sequelize, (tables) => {113 expect(tables.sort()).to.eql(['Person', 'SequelizeMeta', 'Task']);114 done();115 });116 },117 {118 migrationFile: 'new/*createPerson',119 }120 );121 });122 });123 describe('migrations with cjs extension', () => {124 it('correctly migrates', function (done) {125 const self = this;126 prepare(127 () => {128 helpers.readTables(self.sequelize, (tables) => {129 expect(tables.sort()).to.contain('Comment');130 done();131 });132 },133 {134 migrationFile: 'cjs/*createComment.cjs',135 }136 );137 });138 });139 describe('migrations with ts extension', () => {140 it('correctly migrates', function (done) {141 const self = this;142 prepare(143 () => {144 helpers.readTables(self.sequelize, (tables) => {145 expect(tables.sort()).to.contain('Typescript');146 done();147 });148 },149 {150 migrationFile: 'ts/*createTypescript.ts',151 }152 );153 });154 });155 describe('migrations to not match .d.ts extension', () => {156 it("doesn't match", function (done) {157 const self = this;158 prepare(159 () => {160 helpers.readTables(self.sequelize, (tables) => {161 expect(tables.sort()).to.not.contain('TypescriptDS');162 done();163 });164 },165 {166 migrationFile: 'ts/*.d.ts',167 }168 );169 });170 });171 describe('custom meta table name', () => {172 it('correctly uses the defined table name', function (done) {173 const self = this;174 prepare(175 () => {176 helpers.readTables(self.sequelize, (tables) => {177 expect(tables.sort()).to.eql([178 'Person',179 'Task',180 'sequelize_meta',181 ]);182 done();183 });184 },185 {186 migrationFile: 'new/*createPerson',187 config: { migrationStorageTableName: 'sequelize_meta' },188 }189 );190 });191 });192 describe('custom meta schema', () => {193 it('correctly uses the defined schema', function (done) {194 prepare(195 () => {196 if (Support.dialectIsPostgres()) {197 helpers.readSchemas(this.sequelize, (schemas) => {198 expect(schemas.sort()).to.eql(['sequelize_schema']);199 // Tables from public should still be the same.200 helpers.readTables(this.sequelize, (tables) => {201 expect(tables.sort()).to.eql(['Person', 'Task']);202 done();203 });204 });205 } else {206 // If not Postgres, the schema option gets prepended to the table name.207 helpers.readTables(this.sequelize, (tables) => {208 expect(tables.sort()).to.eql([209 'Person',210 'Task',211 'sequelize_schema.SequelizeMeta',212 ]);213 done();214 });215 }216 },217 {218 migrationFile: 'new/*createPerson',219 config: { migrationStorageTableSchema: 'sequelize_schema' },220 }221 );222 });223 });224 });225});226describe(Support.getTestDialectTeaser('db:migrate'), () => {227 describe('with config.js', () => {228 const prepare = function (callback) {229 const config = helpers.getTestConfig();230 const configContent = 'module.exports = ' + JSON.stringify(config);231 let result = '';232 return gulp233 .src(Support.resolveSupportPath('tmp'))234 .pipe(helpers.clearDirectory())235 .pipe(helpers.runCli('init'))236 .pipe(helpers.removeFile('config/config.json'))237 .pipe(helpers.copyMigration('createPerson.js'))238 .pipe(helpers.overwriteFile(configContent, 'config/config.js'))239 .pipe(helpers.runCli('db:migrate'))240 .on('error', (e) => {241 callback(e);242 })243 .on('data', (data) => {244 result += data.toString();245 })246 .on('end', () => {247 callback(null, result);248 });249 };250 it('creates a SequelizeMeta table', function (done) {251 prepare(() => {252 helpers.readTables(this.sequelize, (tables) => {253 expect(tables).to.have.length(2);254 expect(tables).to.contain('SequelizeMeta');255 done();256 });257 });258 });259 it('creates the respective table', function (done) {260 prepare(() => {261 helpers.readTables(this.sequelize, (tables) => {262 expect(tables).to.have.length(2);263 expect(tables).to.contain('Person');264 done();265 });266 });267 });268 });269});270describe(Support.getTestDialectTeaser('db:migrate'), () => {271 describe('with config.json and url option', () => {272 const prepare = function (callback) {273 const config = { url: helpers.getTestUrl() };274 const configContent = 'module.exports = ' + JSON.stringify(config);275 let result = '';276 return gulp277 .src(Support.resolveSupportPath('tmp'))278 .pipe(helpers.clearDirectory())279 .pipe(helpers.runCli('init'))280 .pipe(helpers.removeFile('config/config.json'))281 .pipe(helpers.copyMigration('createPerson.js'))282 .pipe(helpers.overwriteFile(configContent, 'config/config.js'))283 .pipe(helpers.runCli('db:migrate'))284 .on('error', (e) => {285 callback(e);286 })287 .on('data', (data) => {288 result += data.toString();289 })290 .on('end', () => {291 callback(null, result);292 });293 };294 it('creates a SequelizeMeta table', function (done) {295 const self = this;296 prepare(() => {297 helpers.readTables(self.sequelize, (tables) => {298 expect(tables).to.have.length(2);299 expect(tables).to.contain('SequelizeMeta');300 done();301 });302 });303 });304 it('creates the respective table', function (done) {305 const self = this;306 prepare(() => {307 helpers.readTables(self.sequelize, (tables) => {308 expect(tables).to.have.length(2);309 expect(tables).to.contain('Person');310 done();311 });312 });313 });314 });315});316describe(Support.getTestDialectTeaser('db:migrate'), () => {317 describe('optional migration parameters', () => {318 const prepare = function (runArgs = '', callback) {319 const config = { url: helpers.getTestUrl() };320 const configContent = 'module.exports = ' + JSON.stringify(config);321 let result = '';322 return gulp323 .src(Support.resolveSupportPath('tmp'))324 .pipe(helpers.clearDirectory())325 .pipe(helpers.runCli('init'))326 .pipe(helpers.removeFile('config/config.json'))327 .pipe(helpers.copyMigration('createPerson.js'))328 .pipe(helpers.copyMigration('renamePersonToUser.js'))329 .pipe(helpers.copyMigration('createTestTableForTrigger.js'))330 .pipe(helpers.copyMigration('createPost.js'))331 .pipe(helpers.overwriteFile(configContent, 'config/config.js'))332 .pipe(helpers.runCli('db:migrate ' + runArgs))333 .on('error', (e) => {334 callback(e);335 })336 .on('data', (data) => {337 result += data.toString();338 })339 .on('end', () => {340 callback(null, result);341 });342 };343 const runCli = function (cliArgs, callback) {344 let result = '';345 // avoid double callbacks346 let done = callback;347 return gulp348 .src(Support.resolveSupportPath('tmp'))349 .pipe(helpers.runCli(cliArgs, { pipeStdout: true, exitCode: 0 }))350 .on('error', (e) => {351 done(e);352 done = () => {};353 })354 .on('data', (data) => {355 result += data.toString();356 })357 .on('end', () => {358 done(null, result);359 });360 };361 it('--to', function (done) {362 const self = this;363 const migrationsPath = Support.resolveSupportPath('assets', 'migrations');364 const migrations = fs.readdirSync(migrationsPath);365 const createTriggers = migrations.filter(366 (migration) => migration.indexOf('createTestTableForTrigger') > -1367 );368 prepare('--to ' + createTriggers, () => {369 helpers.readTables(self.sequelize, (tables) => {370 expect(tables).to.have.length(3);371 expect(tables).to.contain('User');372 expect(tables).to.contain('trigger_test');373 done();374 });375 });376 });377 it('--to full migration in two parts', function (done) {378 const self = this;379 const migrationsPath = Support.resolveSupportPath('assets', 'migrations');380 const migrations = fs.readdirSync(migrationsPath);381 const createTriggers = migrations.filter(382 (migration) => migration.indexOf('createTestTableForTrigger') > -1383 );384 const createPost = migrations.filter(385 (migration) => migration.indexOf('createPost') > -1386 );387 prepare('--to ' + createTriggers, () => {388 helpers.readTables(self.sequelize, (tables) => {389 expect(tables).to.have.length(3);390 expect(tables).to.contain('User');391 expect(tables).to.contain('trigger_test');392 runCli('db:migrate --to ' + createPost, () => {393 helpers.readTables(self.sequelize, (tables) => {394 expect(tables).to.have.length(4);395 expect(tables).to.contain('Post');396 done();397 });398 });399 });400 });401 });402 it('--to should exit with 0 when there are no migrations', function (done) {403 const self = this;404 const migrationsPath = Support.resolveSupportPath('assets', 'migrations');405 const migrations = fs.readdirSync(migrationsPath);406 const createTriggers = migrations.filter(407 (migration) => migration.indexOf('createTestTableForTrigger') > -1408 );409 prepare('--to ' + createTriggers, () => {410 helpers.readTables(self.sequelize, (tables) => {411 expect(tables).to.have.length(3);412 expect(tables).to.contain('User');413 runCli('db:migrate --to ' + createTriggers, (err, result) => {414 expect(result).to.contain(415 'No migrations were executed, database schema was already up to date.'416 );417 done(err);418 });419 });420 });421 });422 it('--from', function (done) {423 const self = this;424 const migrationsPath = Support.resolveSupportPath('assets', 'migrations');425 const migrations = fs.readdirSync(migrationsPath);426 const createPersonMigration = migrations.filter(427 (migration) => migration.indexOf('renamePersonToUser') > -1428 );429 prepare('--from ' + createPersonMigration, () => {430 helpers.readTables(self.sequelize, (tables) => {431 expect(tables).to.have.length(3);432 expect(tables).to.contain('Post');433 expect(tables).to.contain('trigger_test');434 done();435 });436 });437 });438 it('--from should exit with 0 when there are no migrations', function (done) {439 const self = this;440 const migrationsPath = Support.resolveSupportPath('assets', 'migrations');441 const migrations = fs.readdirSync(migrationsPath);442 const createPersonMigration = migrations.filter(443 (migration) => migration.indexOf('renamePersonToUser') > -1444 );445 const createPost = migrations.filter(446 (migration) => migration.indexOf('createPost') > -1447 );448 prepare('--from ' + createPersonMigration, () => {449 helpers.readTables(self.sequelize, (tables) => {450 expect(tables).to.have.length(3);451 expect(tables).to.contain('Post');452 expect(tables).to.contain('trigger_test');453 runCli('db:migrate --from ' + createPost, (err, result) => {454 expect(result).to.contain(455 'No migrations were executed, database schema was already up to date.'456 );457 done(err);458 });459 });460 });461 });462 it('--to and --from together', function (done) {463 const self = this;464 const migrationsPath = Support.resolveSupportPath('assets', 'migrations');465 const migrations = fs.readdirSync(migrationsPath);466 const createPersonMigration = migrations.filter(467 (migration) => migration.indexOf('renamePersonToUser') > -1468 );469 const createPost = migrations.filter(470 (migration) => migration.indexOf('createTestTableForTrigger') > -1471 );472 prepare('--from ' + createPersonMigration + ' --to ' + createPost, () => {473 helpers.readTables(self.sequelize, (tables) => {474 expect(tables).to.have.length(2);475 expect(tables).to.contain('trigger_test');476 done();477 });478 });479 });480 });...

Full Screen

Full Screen

link-list.component.ts

Source:link-list.component.ts Github

copy

Full Screen

...29 private dialogService: DialogService,30 private i18nService: I18nService) {31 }32 ngOnInit() {33 this.readTables();34 }35 async readTables(): Promise<any> {36 try {37 this.tableLoading = true;38 const data = await this.linkService.get(this.filter).toPromise();39 this.rows = data.result;40 this.meta = data.meta;41 this.tableLoading = false;42 } catch (err) {43 this.tableLoading = false;44 }45 }46 async delete(id: string): Promise<any> {47 try {48 this.tableLoading = true;49 const confirmed = await this.dialogService.confirm('confirm delete?');50 if (confirmed) {51 this.tableLoading = true;52 await this.linkService.delete(id).toPromise();53 this.toasterService.pop('success', '', this.i18nService.instant('panel.message.delete_message'));54 }55 if (this.rows.length === 1 && this.filter.page - 1 > 0) {56 this.filter.page -= 1;57 }58 this.readTables();59 } catch (err) {60 this.toasterService.pop('error', 'Error', err);61 this.tableLoading = false;62 }63 }64 // 创建65 async onSubmit(): Promise<any> {66 try {67 if (this.funcName === 'updateCategory') {68 this.message = 'panel.message.update_message';69 } else {70 this.message = 'panel.message.store_message';71 }72 await this.linkService[this.funcName](this.link).toPromise();73 this.readTables();74 this.editModal.hide();75 this.toasterService.pop('success', '', this.i18nService.instant(this.message));76 } catch (err) {77 this.toasterService.pop('error', 'Error', err.message);78 }79 }80 async switchEnable(data: any): Promise<any> {81 try {82 await this.linkService.update(data).toPromise();83 await this.readTables();84 } catch (err) {85 this.toasterService.pop('error', 'Error', err.message);86 }87 }88 openModal(data?: any) {89 if (!_.isUndefined(data)) {90 this.link = data;91 this.funcName = 'update';92 this.editModal.show();93 } else {94 this.link = new IAddIink();95 this.funcName = 'store';96 this.link.linkUrl = 'https://';97 this.editModal.show();98 }99 this.isInitModal = true;100 }101 closeModal(modal) {102 modal.hide();103 this.isInitModal = false;104 }105 // 切换分页106 changePage(event: any): void {107 this.filter.page = event.page;108 this.readTables();109 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const csv = require('csv-parser');5const results = [];6const csvWriter = require('csv-write-stream');7const writer = csvWriter();8const writer2 = csvWriter();9const writer3 = csvWriter();10const writer4 = csvWriter();11const writer5 = csvWriter();12const writer6 = csvWriter();13const writer7 = csvWriter();14const writer8 = csvWriter();15const writer9 = csvWriter();16const writer10 = csvWriter();17const writer11 = csvWriter();18const writer12 = csvWriter();19const writer13 = csvWriter();20const writer14 = csvWriter();21const writer15 = csvWriter();22const writer16 = csvWriter();23const writer17 = csvWriter();24const writer18 = csvWriter();25const writer19 = csvWriter();26const writer20 = csvWriter();27const writer21 = csvWriter();28const writer22 = csvWriter();29const writer23 = csvWriter();30const writer24 = csvWriter();31const writer25 = csvWriter();32const writer26 = csvWriter();33const writer27 = csvWriter();34const writer28 = csvWriter();35const writer29 = csvWriter();36const writer30 = csvWriter();37const writer31 = csvWriter();38const writer32 = csvWriter();39const writer33 = csvWriter();40const writer34 = csvWriter();41const writer35 = csvWriter();42const writer36 = csvWriter();43const writer37 = csvWriter();44const writer38 = csvWriter();45const writer39 = csvWriter();46const writer40 = csvWriter();47const writer41 = csvWriter();48const writer42 = csvWriter();49const writer43 = csvWriter();50const writer44 = csvWriter();51const writer45 = csvWriter();52const writer46 = csvWriter();53const writer47 = csvWriter();54const writer48 = csvWriter();55const writer49 = csvWriter();56const writer50 = csvWriter();57const writer51 = csvWriter();58const writer52 = csvWriter();59const writer53 = csvWriter();60const writer54 = csvWriter();61const writer55 = csvWriter();62const writer56 = csvWriter();63const writer57 = csvWriter();64const writer58 = csvWriter();65const writer59 = csvWriter();66const writer60 = csvWriter();67const writer61 = csvWriter();68const writer62 = csvWriter();69const writer63 = csvWriter();70const writer64 = csvWriter();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var fs = require('fs');3var file = fs.readFileSync('test.xlsx');4var tables = wptoolkit.readTables(file);5console.log(tables);6var wptoolkit = require('wptoolkit');7var fs = require('fs');8var file = fs.readFileSync('test.xlsx');9var tables = wptoolkit.readTablesSync(file);10console.log(tables);11var wptoolkit = require('wptoolkit');12var fs = require('fs');13var file = fs.readFileSync('test.xlsx');14wptoolkit.readTablesAsync(file, function (tables) {15 console.log(tables);16});17var wptoolkit = require('wptoolkit');18var fs = require('fs');19var file = fs.readFileSync('test.xlsx');20var table = wptoolkit.readTable(file, 1);21console.log(table);22var wptoolkit = require('wptoolkit');23var fs = require('fs');24var file = fs.readFileSync('test.xlsx');25var table = wptoolkit.readTableSync(file, 1);26console.log(table);27var wptoolkit = require('wptoolkit');28var fs = require('fs');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2function callback(err, page) {3 if(err) {4 console.log(err);5 } else {6 var infobox = page.infobox();7 console.log(infobox);8 var tables = page.tables();9 console.log(tables);10 }11}12wptools.page('Wikipedia:List of online newspaper archives', {format: 'json'}).get_tables(callback);

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful