Skip to content

Commit cbc1e81

Browse files
committed
add test
1 parent 7950c4c commit cbc1e81

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

examples/test.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,25 @@ async function test() {
77
'127.0.0.1',
88
2003
99
)
10-
10+
const spaceName = `testTable${Date.now()}Space`;
11+
const tableName = `${spaceName}.testTable`;
1112
const db = await config.connect()
12-
// await db.query('create space testmyspace')
13-
await db.query('USE testmyspace')
14-
// await db.query("create model testmyspace.user(username: string, password: string)")
15-
const res = await db.query(
16-
'SELECT all * FROM int limit ?',
17-
100
18-
)
19-
// await db.query(
20-
// 'insert into testmyspace.user(?, ?)',
21-
// 'test2',
22-
// `a123456`,
23-
// )
24-
// const res = await db.query(
25-
// 'SELECT * FROM mymodel where username = ?',
26-
// 'sayan6'
27-
// )
28-
29-
// const res = await db.query(
30-
// 'SELECT * FROM testmyspace.int where username = ?',
31-
// 10001n
32-
// )
3313

34-
console.log(res, 'result=========');
14+
try {
15+
await db.query('create space ' + spaceName)
16+
await db.query('use ' + spaceName)
17+
await db.query(`CREATE MODEL ${tableName}(username: string, password: string, null email_id: string)`)
18+
await db.query(
19+
`INSERT INTO ${tableName} { username: ?, password: ?, email_id: ? }`,
20+
'test',
21+
'password',
22+
null
23+
)
24+
} finally {
25+
// db.query('DROP SPACE ALLOW NOT EMPTY ' + spaceName)
3526

27+
config.disconnect();
28+
}
3629
}
3730

3831
test()

src/skytable.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type ConnectionTlsOptions = ConnectionOptions & { certFile: string };
1212

1313
type ColumnBase = string | number | boolean | null | bigint;
1414

15-
export type SQParam = ColumnBase;
15+
export type SQParam<T = ColumnBase> = T | SQParam<T>[];
1616

1717
export type ColumnBinary = typeof Buffer;
1818

@@ -36,8 +36,12 @@ export function createSkytable(connection: Socket | TLSSocket) {
3636
const requestData = ['S', data.join('').length, '\n', ...data];
3737
const buffer = Buffer.from(requestData.join(''), 'utf-8');
3838

39+
console.log(dataframe, '===========query==========');
40+
3941
const res = await connectionWrite(connection, buffer);
4042

43+
console.log(res, '===============result==========');
44+
4145
return formatResponse(res);
4246
};
4347

0 commit comments

Comments
 (0)