Skip to content

Commit 1cc0466

Browse files
committed
HACKS
1 parent 91c943a commit 1cc0466

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ export declare class Statement {
4444
raw(raw?: boolean | undefined | null): this
4545
get(params?: unknown | undefined | null): unknown
4646
safeIntegers(toggle?: boolean | undefined | null): this
47+
interrupt(): void
4748
}
4849
export declare class RowsIterator { }

promise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class Statement {
268268
async all(...bindParameters) {
269269
try {
270270
const result = [];
271-
const iterator = this.iterate(...bindParameters);
271+
const iterator = await this.iterate(...bindParameters);
272272
let next;
273273
while (!(next = iterator.next()).done) {
274274
result.push(next.value);

src/lib.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,18 @@ impl Database {
307307
}
308308

309309
#[napi]
310-
pub fn interrupt(&self) -> Result<()> {
311-
todo!();
310+
pub fn interrupt(&self, env: Env) -> Result<()> {
311+
let rt = runtime()?;
312+
let conn = match &self.conn {
313+
Some(conn) => conn.clone(),
314+
None => return Err(throw_database_closed_error(&env).into()),
315+
};
316+
rt.block_on(async move {
317+
let conn = conn.lock().await;
318+
conn.interrupt()
319+
})
320+
.map_err(Error::from)?;
321+
Ok(())
312322
}
313323

314324
#[napi]
@@ -698,6 +708,17 @@ impl Statement {
698708
.store(toggle.unwrap_or(true), Ordering::SeqCst);
699709
Ok(self)
700710
}
711+
712+
#[napi]
713+
pub fn interrupt(&self) -> Result<()> {
714+
let rt = runtime()?;
715+
rt.block_on(async move {
716+
let mut stmt = self.stmt.lock().await;
717+
stmt.interrupt()
718+
})
719+
.map_err(Error::from)?;
720+
Ok(())
721+
}
701722
}
702723

703724
#[napi]

0 commit comments

Comments
 (0)