@cocreate/crud-client
Advanced tools
Comparing version 1.33.6 to 1.33.7
{ | ||
"name": "@cocreate/crud-client", | ||
"version": "1.33.6", | ||
"version": "1.33.7", | ||
"description": "An useful CRUD api operate Create, read, update, delete with built in database. Can be used as a firebase alternative. Easily configured using HTML5 attributes and/or JavaScript API.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -31,4 +31,4 @@ /******************************************************************************** | ||
define(["@cocreate/socket-client", "@cocreate/indexeddb", "@cocreate/utils"], | ||
function (CoCreateSocket, indexeddb, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames }) { | ||
return factory(true, CoCreateSocket, indexeddb = indexeddb.default, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames }); | ||
function (CoCreateSocket, indexeddb, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames, isValidDate }) { | ||
return factory(true, CoCreateSocket, indexeddb = indexeddb.default, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames, isValidDate }); | ||
} | ||
@@ -39,4 +39,4 @@ ) | ||
const CoCreateSocket = require("@cocreate/socket-client"); | ||
const { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames } = require("@cocreate/utils"); | ||
module.exports = factory(false, CoCreateSocket, null, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames }); | ||
const { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames, isValidDate } = require("@cocreate/utils"); | ||
module.exports = factory(false, CoCreateSocket, null, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames, isValidDate }); | ||
} | ||
@@ -46,3 +46,3 @@ else { | ||
} | ||
}(typeof self !== 'undefined' ? self : this, function (isBrowser, CoCreateSocket, indexeddb, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames }) { | ||
}(typeof self !== 'undefined' ? self : this, function (isBrowser, CoCreateSocket, indexeddb, { ObjectId, getValueFromObject, getAttributeNames, setAttributeNames, isValidDate }) { | ||
@@ -158,20 +158,48 @@ const CoCreateCRUD = { | ||
let response = await indexeddb.send({ | ||
let response = { | ||
clientId: data.clientId, | ||
frameId: data.frameId, | ||
socketId: data.socketId, | ||
method: type + '.update', | ||
array: data.array, | ||
[type]: data[type][i], | ||
$filter: { | ||
query: { [key]: { $lt: value } }, | ||
}, | ||
upsert: true, | ||
method: type + '.read', | ||
user_id: data.user_id, | ||
organization_id: data.organization_id | ||
}) | ||
} | ||
if (response && response[type] && response[type].length) { | ||
console.log('crud synced: ', response[type]) | ||
if (type === 'object') { | ||
response[type] = { _id: data[type][i]._id } | ||
response.array = data.array | ||
} else { | ||
response[type] = data[type][i].name | ||
} | ||
response = await indexeddb.send(response) | ||
if (!response[type].length || !response[type][0].organization_id) { | ||
response.method = type + '.create' | ||
response[type] = data[type][i] | ||
response = await indexeddb.send(response) | ||
self.socket.sendLocalMessage(response) | ||
} else { | ||
let queryValue = value | ||
let dataValue = getValueFromObject(response[type][0], key) | ||
if (isValidDate(queryValue) && isValidDate(dataValue)) { | ||
queryValue = new Date(queryValue) | ||
dataValue = new Date(dataValue) | ||
} else if (!response[type][0].organization_id) { | ||
console.log('invalid date') | ||
} | ||
if (dataValue < queryValue) { | ||
console.log('crud synced: ', response[type]) | ||
if (data[type][i].subscriptionItemId) | ||
console.log('test') | ||
response.method = type + '.update' | ||
response[type] = data[type][i] | ||
response = await indexeddb.send(response) | ||
self.socket.sendLocalMessage(response) | ||
} | ||
} | ||
@@ -178,0 +206,0 @@ } |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199494
536