Skip to content

Commit 029f963

Browse files
committed
fix: crud attributes renamed
1 parent 5150fe8 commit 029f963

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

CoCreate.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = {
44
"host": "",
55
"sources": [
66
{
7-
"collection": "files",
8-
"document": {
7+
"array": "files",
8+
"object": {
99
"_id": "637ca64c50234ef1671ce332",
1010
"name": "index.html",
1111
"path": "/docs/server-side-render/index.html",

docs/index.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626
</head>
2727

2828
<body>
29-
<div
30-
collection=""
31-
document_id=""
32-
name=""
33-
id="cocreate-server-side-render">
29+
<div array="" object="" name="" id="cocreate-server-side-render">
3430
<div
3531
class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
3632
<div class="display:flex align-items:center">
@@ -158,8 +154,8 @@ <h4>
158154
<textarea
159155
type="code"
160156
lang="html"
161-
collection="demos"
162-
document_id=""
157+
array="demos"
158+
object=""
163159
name="demo"
164160
save="false"
165161
id="demo"

src/index.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CoCreateServerSideRender {
1616
async function render(html, lastKey) {
1717
const dom = parse(html);
1818
for (let el of dom.querySelectorAll(
19-
"[collection][name][document_id]"
19+
"[array][name][object]"
2020
)) {
2121
let meta = el.attributes;
2222

@@ -34,33 +34,34 @@ class CoCreateServerSideRender {
3434

3535
if (el.hasAttribute('actions'))
3636
continue;
37-
let _id = meta["document_id"],
38-
collection = meta['collection'],
37+
let _id = meta["object"],
38+
array = meta['array'],
3939
name = meta['name'];
40-
let key = _id + collection + name;
41-
if (!_id || !name || !collection) continue;
42-
if (!checkValue(_id) || !checkValue(name) || !checkValue(collection)) continue;
40+
let key = _id + array + name;
41+
if (!_id || !name || !array) continue;
42+
if (!checkValue(_id) || !checkValue(name) || !checkValue(array)) continue;
4343
if (dep.includes(key))
4444
throw new Error(
45-
`infinite loop: ${lastKey} ${collection} ${name} ${_id} has been already rendered`
45+
`infinite loop: ${lastKey} ${array} ${name} ${_id} has been already rendered`
4646
);
4747
else
4848
dep.push(key)
4949

50-
let cacheKey = _id + collection;
50+
let cacheKey = _id + array;
5151
let record;
5252
if (dbCache.has(cacheKey))
5353
record = dbCache.get(cacheKey)
5454
else {
55-
record = await self.crud.readDocument({
56-
collection,
57-
document: {
55+
record = await self.crud.send({
56+
method: 'read.object',
57+
array,
58+
object: {
5859
_id
5960
},
6061
organization_id
6162
});
62-
if (record && record.document && record.document[0])
63-
record = record.document[0]
63+
if (record && record.object && record.object[0])
64+
record = record.object[0]
6465

6566
dbCache.set(cacheKey, record)
6667
}

0 commit comments

Comments
 (0)