Skip to content

Commit 3ec0ea4

Browse files
committed
fix: crud attributes renamed
1 parent 7b69997 commit 3ec0ea4

File tree

6 files changed

+63
-125
lines changed

6 files changed

+63
-125
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": "601460b19f64ba1680b8669b",
1010
"name": "index.html",
1111
"path": "/docs/docs/index.html",

docs/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<link
3030
rel="stylesheet"
3131
href="/docs/index.css"
32-
collection="files"
33-
document_id="60888216117c640e7596303f"
32+
array="files"
33+
object="60888216117c640e7596303f"
3434
name="src"
3535
type="text/css"
3636
save="true" />
@@ -44,8 +44,8 @@
4444
scroll="sticky-nav,hide-nav"
4545
scroll-up="10"
4646
scroll-down="10"
47-
collection="files"
48-
document_id="60395ef42b3ac232657040fd"
47+
array="files"
48+
object="60395ef42b3ac232657040fd"
4949
name="src"></nav>
5050
<sidenav
5151
id="menuL"
@@ -55,8 +55,8 @@
5555
resize-property="margin-left"
5656
resize-value="width">
5757
<menu
58-
collection="files"
59-
document_id="603717b07de7fb350ae9fec8"
58+
array="files"
59+
object="603717b07de7fb350ae9fec8"
6060
name="src"></menu>
6161
<div resize="right"></div>
6262
</sidenav>
@@ -281,8 +281,8 @@ <h2 class="padding:5px_0px">Demo</h2>
281281
<textarea
282282
type="code"
283283
lang="html"
284-
collection="demos"
285-
document_id=""
284+
array="demos"
285+
object=""
286286
name="demo"
287287
save="false"
288288
id="demo"

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ExtractComment {
2828

2929
}
3030

31-
run(filePath, collection, name) {
31+
run(filePath, array, name) {
3232
let content = fs.readFileSync(filePath, 'utf8');
3333
let extension = path.extname(filePath)
3434

@@ -45,7 +45,7 @@ class ExtractComment {
4545
let ret_value = this.extractValue(value)
4646
if (ret_value) {
4747
docItems.push({
48-
collection,
48+
array,
4949
data: {
5050
[name]: ret_value,
5151
extension,

test_files/CoCreate.js

Lines changed: 44 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,47 @@
11

2-
/**
3-
@value_start
4-
updateDocument({
5-
collection: "test123",
6-
document_id: "document_id",
7-
document:{
8-
example: “some example can be html json etc”,
9-
description: “update documnets if document does not exist otherwise create”
10-
},
11-
})
12-
@value_end
13-
*/
14-
updateDocument: function(info) {
15-
if ( !info || !info['document_id'] ) return;
16-
17-
let request_data = this.getCommonParams();
18-
request_data['collection'] = info['collection'] || 'module_activities';
19-
request_data['document_id'] = info['document_id'];
20-
21-
if ( typeof info['data'] === 'object' ) request_data['set'] = info['data'];
22-
if ( Array.isArray(info['delete_fields']) ) request_data['unset'] = info['delete_fields'];
23-
24-
if (!request_data['set'] && !request_data['unset']) return;
25-
26-
request_data['element'] = info['element'];
27-
request_data['metadata'] = info['metadata'];
28-
29-
if (info.broadcast === false) {
30-
request_data['broadcast'] = false;
31-
}
32-
33-
const room = this.generateSocketClient(info.namespace, info.room);
34-
CoCreateSocket.send('updateDocument', request_data, room);
2+
/**
3+
@value_start
4+
crud.send({
5+
method: ''
6+
array: "test123",
7+
object: "object",
8+
object:{
9+
example: “some example can be html json etc”,
10+
description: “update documnets if object does not exist otherwise create”
3511
},
12+
})
13+
@value_end
14+
*/
15+
16+
17+
18+
/**
19+
@value_start
20+
crud.send({
21+
method: "",
22+
array: "test123",
23+
object: "object",
24+
element: “xxxx”,
25+
metaData: "xxxx",
26+
exclude_fields: []
27+
})
28+
@value_end
29+
*/
30+
31+
32+
/**
33+
* @value_start
34+
crud.send({
35+
namespace: '',
36+
room: '',
37+
broadcast: true/false,
38+
broadcastSender: true/false,
3639
37-
38-
/**
39-
@value_start
40-
readDocument({
41-
collection: "test123",
42-
document_id: "document_id",
43-
element: “xxxx”,
44-
metaData: "xxxx",
45-
exclude_fields: []
46-
})
47-
@value_end
48-
*/
49-
readDocument: function(info) {
50-
if (info === null) {
51-
return;
52-
}
53-
if (!info['document_id'] || !info) {
54-
return;
55-
}
56-
57-
let request_data = this.getCommonParams();
58-
request_data['collection'] = info['collection'];
59-
request_data['document_id'] = info['document_id'];
60-
if (info['exclude_fields']) {
61-
request_data['exclude_fields'] = info['exclude_fields'];
62-
}
63-
64-
if (info['element']) {
65-
request_data['element'] = info['element'];
66-
}
67-
68-
request_data['metadata'] = info['metadata']
69-
CoCreateSocket.send('readDocument', request_data);
70-
},
71-
72-
73-
/**
74-
* @value_start
75-
deleteDocument({
76-
namespace: '',
77-
room: '',
78-
broadcast: true/false,
79-
broadcastSender: true/false,
80-
81-
collection: "module",
82-
document: {_id: ""},
83-
element: “xxxx”,
84-
metadata: "xxxx"
85-
})
86-
@value_end
87-
*/
88-
deleteDocument: function(info) {
89-
if (!info['document_id'] || !info) {
90-
return;
91-
}
92-
93-
let request_data = this.getCommonParams();
94-
request_data['collection'] = info['collection'];
95-
request_data['document_id'] = info['document_id'];
96-
97-
if (info['element']) {
98-
request_data['element'] = info['element'];
99-
}
100-
101-
request_data['metadata'] = info['metadata']
102-
103-
const room = this.generateSocketClient(info.namespace, info.room);
104-
CoCreateSocket.send('deleteDocument', request_data, room);
105-
}
40+
method: 'delete.object'
41+
array: "module",
42+
object: {_id: ""},
43+
element: “xxxx”,
44+
metadata: "xxxx"
45+
})
46+
@value_end
47+
*/

test_files/test.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
<body class="padding-20px">
2020
<button actions="import">Import</button>
2121

22-
<button actions="export" collection="" pass_id="datatable">
23-
Export
24-
</button>
22+
<button actions="export" array="" pass_id="datatable">Export</button>
2523

2624
<script>
2725
var CoCreateConfig = {
@@ -43,29 +41,29 @@
4341
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
4442

4543
<script>
46-
let button = document.getElementById("import_btn");
44+
let button = object.getElementById("import_btn");
4745
let selectedFile = null;
4846
button.addEventListener("click", function () {
49-
var input = document.createElement("input");
47+
var input = object.createElement("input");
5048
input.type = "file";
5149

5250
input.onchange = (e) => {
5351
var file = e.target.files[0];
5452
selectedFile = e.target.files[0];
5553

5654
CoCreate.importCollection({
57-
collection: "import_test",
55+
array: "import_test",
5856
file: file,
5957
});
6058
};
6159

6260
input.click();
6361
});
6462

65-
let exportBtn = document.getElementById("export_btn");
63+
let exportBtn = object.getElementById("export_btn");
6664
exportBtn.addEventListener("click", function () {
6765
CoCreate.exportCollection({
68-
collection: "users",
66+
array: "users",
6967
export_type: "csv",
7068
});
7169
});

test_files/test2.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
<body class="padding-20px">
1919
<button actions="import">Import</button>
2020

21-
<button actions="import" collection="" pass_id="datatable">
22-
Export
23-
</button>
21+
<button actions="import" array="" pass_id="datatable">Export</button>
2422

2523
<script>
2624
var CoCreateConfig = {

0 commit comments

Comments
 (0)