-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose stats beneath tables property. Update README and examples
- Loading branch information
1 parent
079177f
commit aebb3f3
Showing
5 changed files
with
113 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint no-console: 0 */ | ||
const { Scanner } = require('..'); | ||
|
||
const config = { | ||
host: 'localhost', | ||
port: 5432, | ||
database: 'postgres', | ||
user: 'postgres', | ||
password: 'postgres', | ||
}; | ||
|
||
const excluded = [ | ||
'ignore_me', | ||
'ignore_me_too', | ||
]; | ||
|
||
const filter = ({ schema, table }) => { | ||
if (excluded.includes(`${schema}.${table}`)) return false; | ||
return true; | ||
}; | ||
|
||
const scanner = new Scanner({ config, filter }); | ||
|
||
(async () => { | ||
await scanner.init(); | ||
scheduleScan(1000); | ||
})(); | ||
|
||
function scheduleScan(delay) { | ||
setTimeout(async () => { | ||
const stats = await scanner.scan(); | ||
dump(stats); | ||
scheduleScan(delay); | ||
}, delay); | ||
} | ||
|
||
function dump(stats) { | ||
const serializer = (_, value) => (typeof value === 'bigint' ? value.toString() : value); | ||
const text = JSON.stringify(stats, serializer); | ||
console.log(text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters