From 63ab77fa919feb960de7ceed20a7969d4d83098f Mon Sep 17 00:00:00 2001 From: temple06 Date: Wed, 26 Aug 2020 09:57:32 -0400 Subject: [PATCH] add table.rows.clear() method https://github.com/tediousjs/node-mssql/issues/1087 --- lib/table.js | 7 +++++++ test/common/unit.js | 3 +++ 2 files changed, 10 insertions(+) diff --git a/lib/table.js b/lib/table.js index d22950ad..fd47c852 100644 --- a/lib/table.js +++ b/lib/table.js @@ -48,6 +48,13 @@ function Table (name) { } } ) + + Object.defineProperty(this.rows, 'clear', { + value () { + return this.splice(0, this.length) + } + } + ) } /* diff --git a/test/common/unit.js b/test/common/unit.js index 76a9ffcf..615219ec 100644 --- a/test/common/unit.js +++ b/test/common/unit.js @@ -140,6 +140,9 @@ describe('Unit', () => { assert.deepStrictEqual(t.rows[3], [12, 'XCXCDCDSCDSC']) assert.strictEqual(t.temporary, false) + t.rows.clear() + assert.strictEqual(t.rows.length, 0) + t = new sql.Table('schm.MyTable') assert.strictEqual(t.name, 'MyTable')