loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.285918937870383","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"Y29uc3QgQXBwYmFzZSA9IHJlcXVpcmUoImFwcGJhc2UtanMiKTsKCi8vIENyZWF0ZSBhcHBiYXNlIGluc3RhbmNlIHRvIHVzZSBtZXRob2RzCmNvbnN0IGFwcGJhc2VSZWYgPSBBcHBiYXNlKHsKICB1cmw6ICJodHRwczovL3NjYWxyLmFwaS5hcHBiYXNlLmlvIiwKICBhcHA6ICJuZXdzdHJlYW1pbmdhcHAiLAogIGNyZWRlbnRpYWxzOiAibWVxUmY4S0pDOjY1Y2MxNjFhLTIyYWQtNDBjNS1hYWFmLTVjMDgyZDVkY2ZkYSIKfSk7CgovLyBBcnJheSBvZiBkYXRhIG9iamVjdHMKY29uc3QgZGF0YUFycmF5ID0gWwogIHsKICAgIGlkOiAiWDEiLAogICAgZGVwYXJ0bWVudF9uYW1lOiAiQm9va3MiLAogICAgZGVwYXJ0bWVudF9uYW1lX2FuYWx5emVkOiAiQm9va3MiLAogICAgZGVwYXJ0bWVudF9pZDogMSwKICAgIG5hbWU6ICJBIEZha2UgQm9vayBvbiBOZXR3b3JrIFJvdXRpbmciLAogICAgcHJpY2U6IDEwMzIKICB9LAogIHsKICAgIGlkOiAiWDIiLAogICAgZGVwYXJ0bWVudF9uYW1lOiAiQm9va3MiLAogICAgZGVwYXJ0bWVudF9uYW1lX2FuYWx5emVkOiAiQm9va3MiLAogICAgZGVwYXJ0bWVudF9pZDogMiwKICAgIG5hbWU6ICJBIEZha2UgQm9vayBvbiBDb21wdXRlciBTY2llbmNlIiwKICAgIHByaWNlOiA0MTI1CiAgfSwKICB7CiAgICBpZDogIlgzIiwKICAgIGRlcGFydG1lbnRfbmFtZTogIkJvb2tzIiwKICAgIGRlcGFydG1lbnRfbmFtZV9hbmFseXplZDogIkJvb2tzIiwKICAgIGRlcGFydG1lbnRfaWQ6IDMsCiAgICBuYW1lOiAiQSBGYWtlIEJvb2sgb24gUmVhY3RpdmUgUHJvZ3JhbW1pbmciLAogICAgcHJpY2U6IDM4NDYKICB9Cl07CgpsZXQgcmVxdWVzdEJvZHkgPSBbXTsKCi8vIENyZWF0aW5nIHJlcXVlc3QgYm9keQpkYXRhQXJyYXkuZm9yRWFjaChkYXRhID0+IHsKICAvLyBQdXNoaW5nIHRoZSBvcGVyYXRpb24gYW5kIF9pZCBmb3IgZWFjaCByZXF1ZXN0CiAgcmVxdWVzdEJvZHkucHVzaCh7CiAgICBpbmRleDogewogICAgICBfaWQ6IGRhdGEuaWQKICAgIH0KICB9KTsKICByZXF1ZXN0Qm9keS5wdXNoKGRhdGEpOwp9KTsKCi8vIEJ1bGsgcmVxdWVzdCBpbmNsdWRpbmcgdGhlIGluZGV4IG1ldGhvZCBhbmQgYWxsIGRhdGEgb2JqZWN0cwphcHBiYXNlUmVmCiAgLmJ1bGsoewogICAgdHlwZTogImJvb2tzIiwKICAgIGJvZHk6IHJlcXVlc3RCb2R5CiAgfSkKICAudGhlbihyZXNwb25zZSA9PiB7CiAgICBjb25zb2xlLmxvZygiU3VjY2VzczogIiwgSlNPTi5zdHJpbmdpZnkocmVzcG9uc2UsIG51bGwsICJcdCIpKTsKICB9KQogIC5jYXRjaChlcnJvciA9PiB7CiAgICBjb25zb2xlLmxvZygiRXJyb3I6ICIsIGVycm9yKTsKICB9KTs="},"asBuffer":null},"loaded":true}}
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const Appbase = require("appbase-js");

// Create appbase instance to use methods
const appbaseRef = Appbase({
  url: "https://scalr.api.appbase.io",
  app: "newstreamingapp",
  credentials: "meqRf8KJC:65cc161a-22ad-40c5-aaaf-5c082d5dcfda"
});

// Array of data objects
const dataArray = [
  {
    id: "X1",
    department_name: "Books",
    department_name_analyzed: "Books",
    department_id: 1,
    name: "A Fake Book on Network Routing",
    price: 1032
  },
  {
    id: "X2",
    department_name: "Books",
    department_name_analyzed: "Books",
    department_id: 2,
    name: "A Fake Book on Computer Science",
    price: 4125
  },
  {
    id: "X3",
    department_name: "Books",
    department_name_analyzed: "Books",
    department_id: 3,
    name: "A Fake Book on Reactive Programming",
    price: 3846
  }
];

let requestBody = [];

// Creating request body
dataArray.forEach(data => {
  // Pushing the operation and _id for each request
  requestBody.push({
    index: {
      _id: data.id
    }
  });
  requestBody.push(data);
});

// Bulk request including the index method and all data objects
appbaseRef
  .bulk({
    type: "books",
    body: requestBody
  })
  .then(response => {
    console.log("Success: ", JSON.stringify(response, null, "\t"));
  })
  .catch(error => {
    console.log("Error: ", error);
  });
node v10.16.0