ferrum-db-client
Advanced tools
Comparing version 0.2.6 to 0.2.8
@@ -9,6 +9,7 @@ import { FerrumServerClient } from './client'; | ||
export declare class CollectionRemote { | ||
protected type: CollectionType; | ||
readonly type: CollectionType; | ||
readonly database: string; | ||
get name(): string; | ||
protected client: FerrumServerClient; | ||
protected collectionKey: string; | ||
protected database: string; | ||
constructor(type: CollectionType, client: FerrumServerClient, database: string, collectionkey: string); | ||
@@ -15,0 +16,0 @@ hasTag(tag?: string): Promise<boolean>; |
@@ -20,2 +20,5 @@ "use strict"; | ||
} | ||
get name() { | ||
return this.collectionKey; | ||
} | ||
async hasTag(tag = '') { | ||
@@ -22,0 +25,0 @@ const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_HAS_TAG, this.database.length + this.collectionKey.length + 1 + tag.length); |
@@ -8,3 +8,3 @@ import { FerrumServerClient } from './client'; | ||
private client; | ||
private dbName; | ||
readonly name: string; | ||
constructor(client: FerrumServerClient, dbName: string); | ||
@@ -11,0 +11,0 @@ createIndexIfNotExist<T>(index: string, encoding?: SupportedEncodingTypes, compression?: SupportedCompressionTypes, pageFileSize?: number): Promise<IndexRemote<T>>; |
@@ -13,7 +13,7 @@ "use strict"; | ||
this.client = client; | ||
this.dbName = dbName; | ||
this.name = dbName; | ||
} | ||
async createIndexIfNotExist(index, encoding = 'bson', compression = 'gzip', pageFileSize = 0) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.dbName.length + index.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.name.length + index.length); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -33,7 +33,7 @@ bw.writeUnsignedInt(pageFileSize); | ||
getIndex(index, encoding = 'bson', compression = 'gzip') { | ||
return new index_remote_1.IndexRemote(this.client, this.dbName, index, encoding, compression); | ||
return new index_remote_1.IndexRemote(this.client, this.name, index, encoding, compression); | ||
} | ||
async deleteIndex(index) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_INDEX, index.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -53,3 +53,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_INDEX, index.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -70,3 +70,3 @@ bw.writeUnsignedInt(pageFileSize); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_INDEX, index.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -86,3 +86,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_INDEXES, 0); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -105,4 +105,4 @@ const response = await this.client.getResponse(myId); | ||
async createSetIfNotExist(set) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.dbName.length + set.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.name.length + set.length); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -121,7 +121,7 @@ this.client.sendMsg(bw); | ||
getSet(set) { | ||
return new set_remote_1.SetRemote(this.client, this.dbName, set); | ||
return new set_remote_1.SetRemote(this.client, this.name, set); | ||
} | ||
async deleteSet(set) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_SET, set.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -141,3 +141,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_SET, set.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -157,3 +157,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_SET, set.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -173,3 +173,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_SETS, 0); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -192,4 +192,4 @@ const response = await this.client.getResponse(myId); | ||
async createTimeSeriesIfNotExist(name, encoding = 'bson', compression = 'gzip', pageFileSize = 0) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.dbName.length + name.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.name.length + name.length); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -209,7 +209,7 @@ bw.writeUnsignedInt(pageFileSize); | ||
getTimeSeries(name, encoding = 'bson', compression = 'gzip') { | ||
return new time_series_remote_1.TimeSeriesRemote(this.client, this.dbName, name, encoding, compression); | ||
return new time_series_remote_1.TimeSeriesRemote(this.client, this.name, name, encoding, compression); | ||
} | ||
async deleteTimeSeries(name) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_TIME_SERIES, name.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -229,3 +229,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_TIME_SERIES, name.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -246,3 +246,3 @@ bw.writeUnsignedInt(pageFileSize); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_TIME_SERIES, name.length); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8); | ||
@@ -262,3 +262,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_TIME_SERIES, 0); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -282,3 +282,3 @@ const response = await this.client.getResponse(myId); | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COMPACT, 0); | ||
bw.writeString(this.dbName, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -285,0 +285,0 @@ const response = await this.client.getResponse(myId); |
@@ -5,2 +5,3 @@ import { FerrumServerClient } from './client'; | ||
export { IndexRemote } from './index_remote'; | ||
export { CollectionType } from './collection_remote'; | ||
export { SetRemote } from './set_remote'; | ||
@@ -7,0 +8,0 @@ export declare function ferrumConnect(ip: string, port: number): Promise<FerrumServerConnection>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FerrumServerConnection = exports.ferrumConnect = exports.SetRemote = exports.IndexRemote = exports.FerrumDBRemote = void 0; | ||
exports.FerrumServerConnection = exports.ferrumConnect = exports.SetRemote = exports.CollectionType = exports.IndexRemote = exports.FerrumDBRemote = void 0; | ||
const csharp_binary_stream_1 = require("csharp-binary-stream"); | ||
@@ -14,2 +14,4 @@ const net_1 = require("net"); | ||
Object.defineProperty(exports, "IndexRemote", { enumerable: true, get: function () { return index_remote_1.IndexRemote; } }); | ||
var collection_remote_1 = require("./collection_remote"); | ||
Object.defineProperty(exports, "CollectionType", { enumerable: true, get: function () { return collection_remote_1.CollectionType; } }); | ||
var set_remote_1 = require("./set_remote"); | ||
@@ -16,0 +18,0 @@ Object.defineProperty(exports, "SetRemote", { enumerable: true, get: function () { return set_remote_1.SetRemote; } }); |
@@ -10,2 +10,4 @@ import { FerrumServerClient } from './client'; | ||
getEntry(serie: string, timestamp: number): Promise<T>; | ||
hasEntry(serie: string, timestamp: number): Promise<boolean>; | ||
deleteEntry(serie: string, timestamp: number): Promise<void>; | ||
getFullSerie(serie: string): Promise<number[]>; | ||
@@ -12,0 +14,0 @@ getFullSerieEntries(serie: string): Promise<T[]>; |
@@ -52,2 +52,34 @@ "use strict"; | ||
} | ||
async hasEntry(serie, timestamp) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_HAS_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length); | ||
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(serie, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeLong(timestamp); | ||
this.client.sendMsg(bw); | ||
const response = await this.client.getResponse(myId); | ||
const br = (0, utils_1.getBinaryReader)(response); | ||
const success = br.readBoolean(); | ||
if (!success) { | ||
return (0, utils_1.handleErrorResponse)(br); | ||
} | ||
else { | ||
return br.readBoolean(); | ||
} | ||
} | ||
async deleteEntry(serie, timestamp) { | ||
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_DELETE_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length); | ||
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeString(serie, csharp_binary_stream_1.Encoding.Utf8); | ||
bw.writeLong(timestamp); | ||
this.client.sendMsg(bw); | ||
const response = await this.client.getResponse(myId); | ||
const br = (0, utils_1.getBinaryReader)(response); | ||
const success = br.readBoolean(); | ||
if (!success) { | ||
return (0, utils_1.handleErrorResponse)(br); | ||
} | ||
return; | ||
} | ||
async getFullSerie(serie) { | ||
@@ -67,3 +99,8 @@ const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FULL_SERIE, this.database.length + this.collectionKey.length + serie.length); | ||
try { | ||
return (0, utils_1.readEncodedDataArray)(br, this.encoding, this.compression); | ||
const count = br.readInt(); | ||
const result = []; | ||
for (let i = 0; i < count; i++) { | ||
result.push(br.readLong()); | ||
} | ||
return result; | ||
} | ||
@@ -70,0 +107,0 @@ catch (e) { |
{ | ||
"name": "ferrum-db-client", | ||
"version": "0.2.6", | ||
"version": "0.2.8", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
@@ -13,6 +13,9 @@ import { Encoding } from 'csharp-binary-stream'; | ||
export class CollectionRemote { | ||
protected type: CollectionType; | ||
public readonly type: CollectionType; | ||
public readonly database: string; | ||
public get name(): string { | ||
return this.collectionKey; | ||
} | ||
protected client: FerrumServerClient; | ||
protected collectionKey: string; | ||
protected database: string; | ||
@@ -19,0 +22,0 @@ constructor(type: CollectionType, client: FerrumServerClient, database: string, collectionkey: string) { |
@@ -11,7 +11,7 @@ import { Encoding } from 'csharp-binary-stream'; | ||
private client: FerrumServerClient; | ||
private dbName: string; | ||
public readonly name: string; | ||
constructor(client: FerrumServerClient, dbName: string) { | ||
this.client = client; | ||
this.dbName = dbName; | ||
this.name = dbName; | ||
} | ||
@@ -25,4 +25,4 @@ | ||
): Promise<IndexRemote<T>> { | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.dbName.length + index.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.name.length + index.length); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(index, Encoding.Utf8); | ||
@@ -45,3 +45,3 @@ bw.writeUnsignedInt(pageFileSize); | ||
public getIndex<T>(index: string, encoding: SupportedEncodingTypes = 'bson', compression: SupportedCompressionTypes = 'gzip'): IndexRemote<T> { | ||
return new IndexRemote<T>(this.client, this.dbName, index, encoding, compression); | ||
return new IndexRemote<T>(this.client, this.name, index, encoding, compression); | ||
} | ||
@@ -51,3 +51,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_INDEX, index.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(index, Encoding.Utf8); | ||
@@ -75,3 +75,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_INDEX, index.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(index, Encoding.Utf8); | ||
@@ -95,3 +95,3 @@ bw.writeUnsignedInt(pageFileSize); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_INDEX, index.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(index, Encoding.Utf8); | ||
@@ -113,3 +113,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_INDEXES, 0); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -134,4 +134,4 @@ | ||
public async createSetIfNotExist(set: string): Promise<SetRemote> { | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.dbName.length + set.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.name.length + set.length); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(set, Encoding.Utf8); | ||
@@ -153,3 +153,3 @@ | ||
public getSet(set: string): SetRemote { | ||
return new SetRemote(this.client, this.dbName, set); | ||
return new SetRemote(this.client, this.name, set); | ||
} | ||
@@ -159,3 +159,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_SET, set.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(set, Encoding.Utf8); | ||
@@ -178,3 +178,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_SET, set.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(set, Encoding.Utf8); | ||
@@ -197,3 +197,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_SET, set.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(set, Encoding.Utf8); | ||
@@ -215,3 +215,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_SETS, 0); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -241,4 +241,4 @@ | ||
): Promise<TimeSeriesRemote<T>> { | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.dbName.length + name.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.name.length + name.length); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(name, Encoding.Utf8); | ||
@@ -261,3 +261,3 @@ bw.writeUnsignedInt(pageFileSize); | ||
public getTimeSeries<T>(name: string, encoding: SupportedEncodingTypes = 'bson', compression: SupportedCompressionTypes = 'gzip'): TimeSeriesRemote<T> { | ||
return new TimeSeriesRemote<T>(this.client, this.dbName, name, encoding, compression); | ||
return new TimeSeriesRemote<T>(this.client, this.name, name, encoding, compression); | ||
} | ||
@@ -267,3 +267,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_TIME_SERIES, name.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(name, Encoding.Utf8); | ||
@@ -291,3 +291,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_TIME_SERIES, name.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(name, Encoding.Utf8); | ||
@@ -311,3 +311,3 @@ bw.writeUnsignedInt(pageFileSize); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_TIME_SERIES, name.length); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
bw.writeString(name, Encoding.Utf8); | ||
@@ -329,3 +329,3 @@ this.client.sendMsg(bw); | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_TIME_SERIES, 0); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -350,3 +350,3 @@ | ||
const { bw, myId } = this.client.getSendWriter(ApiMessageType.COMPACT, 0); | ||
bw.writeString(this.dbName, Encoding.Utf8); | ||
bw.writeString(this.name, Encoding.Utf8); | ||
this.client.sendMsg(bw); | ||
@@ -353,0 +353,0 @@ |
@@ -10,3 +10,3 @@ import { Encoding } from 'csharp-binary-stream'; | ||
export { IndexRemote } from './index_remote'; | ||
export { CollectionType } from './collection_remote'; | ||
export { SetRemote } from './set_remote'; | ||
@@ -13,0 +13,0 @@ |
@@ -69,2 +69,46 @@ import { Encoding } from 'csharp-binary-stream'; | ||
public async hasEntry(serie: string, timestamp: number): Promise<boolean> { | ||
const { bw, myId } = this.client.getSendWriter( | ||
ApiMessageType.TIME_SERIES_HAS_ENTRY, | ||
this.database.length + this.collectionKey.length + 8 + serie.length, | ||
); | ||
bw.writeString(this.database, Encoding.Utf8); | ||
bw.writeString(this.collectionKey, Encoding.Utf8); | ||
bw.writeString(serie, Encoding.Utf8); | ||
bw.writeLong(timestamp); | ||
this.client.sendMsg(bw); | ||
const response = await this.client.getResponse(myId); | ||
const br = getBinaryReader(response); | ||
const success = br.readBoolean(); | ||
if (!success) { | ||
return handleErrorResponse(br); | ||
} else { | ||
return br.readBoolean(); | ||
} | ||
} | ||
public async deleteEntry(serie: string, timestamp: number): Promise<void> { | ||
const { bw, myId } = this.client.getSendWriter( | ||
ApiMessageType.TIME_SERIES_DELETE_ENTRY, | ||
this.database.length + this.collectionKey.length + 8 + serie.length, | ||
); | ||
bw.writeString(this.database, Encoding.Utf8); | ||
bw.writeString(this.collectionKey, Encoding.Utf8); | ||
bw.writeString(serie, Encoding.Utf8); | ||
bw.writeLong(timestamp); | ||
this.client.sendMsg(bw); | ||
const response = await this.client.getResponse(myId); | ||
const br = getBinaryReader(response); | ||
const success = br.readBoolean(); | ||
if (!success) { | ||
return handleErrorResponse(br); | ||
} | ||
return; | ||
} | ||
public async getFullSerie(serie: string): Promise<number[]> { | ||
@@ -88,3 +132,9 @@ const { bw, myId } = this.client.getSendWriter( | ||
try { | ||
return readEncodedDataArray(br, this.encoding, this.compression); | ||
const count = br.readInt(); | ||
const result = []; | ||
for (let i = 0; i < count; i++) { | ||
result.push(br.readLong()); | ||
} | ||
return result; | ||
} catch (e) { | ||
@@ -91,0 +141,0 @@ throw new Error(`Failed to get ${serie} from ${this.collectionKey} \n\nCaused by: ${e}`); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
302503
3514