-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathapp-object-list.js
48 lines (43 loc) · 1.21 KB
/
app-object-list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const createSession = require('../../session');
const properties = {
qInfo: {
qType: 'my-list',
},
qAppObjectListDef: {
qType: 'my-object',
qData: {
title: '/meta/title',
},
},
};
const session = createSession();
// Open the session and create a session document:
session
.open()
.then((global) => global.getActiveDoc())
.then((doc) => {
const tasks = [];
// Create 10 objects of type my-object with unique titles
for (let i = 0; i < 10; i += 1) {
tasks.push(doc.createObject({
qInfo: {
qType: 'my-object',
},
meta: {
title: `my-object${i}`,
},
}));
}
// Create a app object list using qAppObjectListDef and list all objects of type my-object
// and also lists the title for each object.
// eslint-disable-next-line no-restricted-globals
return Promise.all(tasks).then(() => doc
.createObject(properties)
.then((object) => object.getLayout())
.then((layout) => console.log('App object list:', JSON.stringify(layout, null, ' ')))
.then(() => session.close()));
})
.catch((error) => {
console.log('Session: Failed to open socket:', error);
process.exit(1);
});