Skip to content

Commit

Permalink
unique_id updated
Browse files Browse the repository at this point in the history
  • Loading branch information
kriit24 committed Dec 9, 2023
1 parent fcbaa7d commit ea274aa
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
44 changes: 25 additions & 19 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "project-rest-client",
"version": "1.2.0",
"version": "1.2.1",
"description": "Project DB Rest Api client",
"main": "src/index.js",
"react-native": "src/index.js",
Expand Down
14 changes: 1 addition & 13 deletions src/component/ws_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import sync from "./ws_sync";
import WS_stmt from "./ws_stmt";
import WS_fetchdata from "./ws_fetchdata";
import WS_config from "./ws_config";
import unique_id from "./unique_id";
import Base64 from "./base64";

let onPromises = {};

Expand Down Expand Up @@ -91,7 +89,7 @@ class WS_model extends WS_stmt {

insert(data) {

let uniqueId = Base64.btoa(this.table + '_insert_' + unique_id());
let uniqueId = this.unique_id(this.table);
data['data_unique_id'] = uniqueId;

this.addPromise((resolve, reject, data) => {
Expand All @@ -118,9 +116,6 @@ class WS_model extends WS_stmt {

save(data) {

let uniqueId = Base64.btoa(this.table + '_save_' + unique_id());
data['data_unique_id'] = uniqueId;

this.addPromise((resolve, reject, data) => {

let model_sync = new sync(this.table, this.primaryKey, this.updatedAt);
Expand All @@ -139,14 +134,10 @@ class WS_model extends WS_stmt {
resolve(true);
}, Object.assign({}, data));
this.runPromises();

return uniqueId;
}

delete(primary_id) {

let uniqueId = Base64.btoa(this.table + '_save_' + unique_id());

this.addPromise((resolve, reject, data) => {

this
Expand All @@ -164,7 +155,6 @@ class WS_model extends WS_stmt {
let primaryKey = this.primaryKey;
let deleteData = {};
deleteData[primaryKey] = data.primary_id;
deleteData['data_unique_id'] = uniqueId;

let model_sync = new sync(this.table, this.primaryKey, this.updatedAt);
model_sync
Expand All @@ -178,8 +168,6 @@ class WS_model extends WS_stmt {
});
}, Object.assign({}, {primary_id: primary_id}));
this.runPromises();

return uniqueId;
}

fetchAll(callback) {
Expand Down
11 changes: 9 additions & 2 deletions src/component/ws_stmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import WS_config from "./ws_config";
import * as FileSystem from "expo-file-system";
import Ws_crypto from "./ws_crypto";
import canJSON from "project-can-json";
import Base64 from "./base64";
import unique_id from "./unique_id";

class WS_stmt {

Expand Down Expand Up @@ -43,7 +45,7 @@ class WS_stmt {
return WS_config.ws;
}

encrypt(data){
encrypt(data) {

return Ws_crypto.sign(data);
}
Expand Down Expand Up @@ -78,6 +80,11 @@ class WS_stmt {
};
}

unique_id(prefix) {

return Base64.btoa(prefix + Math.floor(new Date().getTime() / 1000) + unique_id());
}

debug() {

this.stmtDebug = true;
Expand Down Expand Up @@ -250,7 +257,7 @@ class WS_stmt {
use(method) {

this.stmtUse.push(method);
if( this.stmtUseCallback === undefined )
if (this.stmtUseCallback === undefined)
this.stmtUseCallback = {};

if (typeof this[method] === "function") {
Expand Down

0 comments on commit ea274aa

Please sign in to comment.