Advertisement
Guest User

Untitled

a guest
Oct 25th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { SteamItem } = require("./models");
  2.  
  3. const run = async () => {
  4.   const lastOne = await SteamItem.findAll({
  5.     limit: 1,
  6.     order: [["id", "DESC"]],
  7.   });
  8.  
  9.   console.log(lastOne[0].id); // 13369
  10.  
  11.   const data = [
  12.     {
  13.       appId: 730,
  14.       marketHashName: "AWP | The Prince (Well-Worn)", // existed
  15.     },
  16.     {
  17.       appId: 730,
  18.       marketHashName: "Autograph Capsule | FaZe Clan | Atlanta 2017", // existed
  19.     },
  20.     {
  21.       appId: 730,
  22.       marketHashName: "new",
  23.     },
  24.     {
  25.       appId: 730,
  26.       marketHashName: "Autograph Capsule | Team EnVyUs | Atlanta 2017", // existed
  27.     },
  28.     {
  29.       appId: 730,
  30.       marketHashName: "Sticker | G2 Esports (Foil) | Cluj-Napoca 2015", // existed
  31.     },
  32.   ];
  33.  
  34.   const res = await SteamItem.bulkCreate(data, {
  35.     ignoreDuplicates: true,
  36.   });
  37.  
  38.   // id of new 13372
  39.  
  40.   const res2 = await SteamItem.bulkCreate(
  41.     [
  42.       {
  43.         appId: 730,
  44.         marketHashName: "newnew",
  45.       },
  46.     ],
  47.     {
  48.       ignoreDuplicates: true,
  49.     }
  50.   );
  51.  
  52.   // id of newnew 13375
  53. };
  54.  
  55. run();
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement