We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d69ea3b commit 1c663e3Copy full SHA for 1c663e3
src/test/index.ts
@@ -0,0 +1,29 @@
1
+interface Group {
2
+ objectId: number;
3
+ name: string;
4
+}
5
+
6
+const test = function (group: Group[] | Group): string {
7
+ const mapping: string[] = Object.keys(group);
8
+ let query: string = '';
9
+ if (mapping[0] === 'objectId') {
10
+ query = `&objectId=${group[mapping[0]]}`;
11
+ } else {
12
+ let i: number = 0;
13
+ while (i < mapping.length) {
14
+ query += `$objectId=${group[i].objectId}`;
15
+ i++;
16
+ }
17
18
19
+ return query;
20
+};
21
22
+const arr = test([
23
+ { objectId: 1, name: 'test' },
24
+ { objectId: 2, name: 'test2' },
25
+]);
26
+const obj = test({ objectId: 1, name: 'test' });
27
28
+console.log('_arr', arr);
29
+console.log('_obj', obj);
0 commit comments