Skip to content

Commit 265f447

Browse files
Update js docs
1 parent b3bb641 commit 265f447

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

packages/modules/postgresql/src/postgresql-container.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,25 @@ export class StartedPostgreSqlContainer extends AbstractStartedContainer {
8787
return url.toString();
8888
}
8989

90+
/**
91+
* Sets the name to be used for database snapshots.
92+
* This name will be used as the default for snapshot() and restore() methods.
93+
*
94+
* @param snapshotName The name to use for snapshots (default is "migrated_template" if this method is not called)
95+
* @returns this (for method chaining)
96+
*/
9097
public withSnapshotName(snapshotName: string): this {
9198
this.snapshotName = snapshotName;
9299
return this;
93100
}
94101

95102
/**
96103
* Takes a snapshot of the current state of the database as a template, which can then be restored using
97-
* the restore method. By default, the snapshot will be created under a database called migrated_template.
98-
*
99-
* If a snapshot already exists under the given/default name, it will be overwritten with the new snapshot.
104+
* the restore method.
100105
*
101-
* @param snapshotName Optional name for the snapshot, defaults to this.snapshotName
106+
* @param snapshotName Name for the snapshot, defaults to the value set by withSnapshotName() or "migrated_template" if not specified
102107
* @returns Promise resolving when snapshot is complete
108+
* @throws Error if attempting to snapshot the postgres system database or if using the same name as the database
103109
*/
104110
public async snapshot(snapshotName = this.snapshotName): Promise<void> {
105111
this.snapshotSanityCheck(snapshotName);
@@ -118,11 +124,11 @@ export class StartedPostgreSqlContainer extends AbstractStartedContainer {
118124
}
119125

120126
/**
121-
* Restores the database to a specific snapshot. By default, it will restore the last snapshot taken on the
122-
* database by the snapshot method. If a snapshot name is provided, it will instead try to restore the snapshot by name.
127+
* Restores the database to a specific snapshot.
123128
*
124-
* @param opts Optional snapshot configuration options
129+
* @param snapshotName Name of the snapshot to restore from, defaults to the value set by withSnapshotName() or "migrated_template" if not specified
125130
* @returns Promise resolving when restore is complete
131+
* @throws Error if attempting to restore the postgres system database or if using the same name as the database
126132
*/
127133
public async restore(snapshotName = this.snapshotName): Promise<void> {
128134
this.snapshotSanityCheck(snapshotName);
@@ -138,7 +144,9 @@ export class StartedPostgreSqlContainer extends AbstractStartedContainer {
138144

139145
/**
140146
* Executes a series of SQL commands against the Postgres database
141-
* @param commands SQL commands to execute
147+
*
148+
* @param commands Array of SQL commands to execute in sequence
149+
* @throws Error if any command fails to execute with details of the failure
142150
*/
143151
private async execCommandsSQL(commands: string[]): Promise<void> {
144152
for (const command of commands) {

0 commit comments

Comments
 (0)