How to use the getRepository function from typeorm

Find comprehensive JavaScript typeorm.getRepository code examples handpicked from public code repositorys.

24
25
26
27
28
29
30
31
32
  await db.cleanup();
  await message.prepare();
});

it('create user1', async () => {
  await getRepository(User).save({
    userName: user1.userName, userId: user1.userId, points: user1.points,
  });
});
fork icon72
star icon0
watch icon1

+ 159 other calls in file

22
23
24
25
26
27
28
29
30
31
  await message.prepare();
});

describe('#2219 - Give points on tip not working', function () {
  before(async function () {
    await getRepository(Event).save({
      id: uuidv4(),
      name: 'tip',
      givenName: 'Tip alert',
      triggered: {},
fork icon72
star icon0
watch icon1

+ 47 other calls in file

151
152
153
154
155
156
157
158
159
          xpOnlineMessages:  3,
        },
      },
    };
    await changelog.flush();
    const user = await getRepository(User).findOne('999999');
    assert.deepEqual(user, expected);
  });
});
fork icon72
star icon0
watch icon0

+ 15 other calls in file

30
31
32
33
34
35
36
37
38
39

})

async function clearTables(models) {
  for (const model of models) {
    await getRepository(model).delete({
      id: MoreThanOrEqual(1)
    })
    console.log('Cleared table ' + model.prototype.constructor.name)
  }
fork icon3
star icon9
watch icon4

+ 15 other calls in file

80
81
82
83
84
85
86
87
88
89
            alreadyRetirado_1 = true;
        }
    }
});
if (!!alreadyRetirado_1) return [3 /*break*/, 5];
retiradoRepo = typeorm_1.getRepository(Retirado_1.default);
retirado = new Retirado_1.default();
retirado.user = user;
return [4 /*yield*/, retiradoRepo.save(retirado)
    // o ID do retirado = 
fork icon0
star icon0
watch icon0

+ 12 other calls in file

5
6
7
8
9
10
11
12
13
14

const validators = {
  name: async name => {
    if (/^[a-zA-Z ]+$/.test(name)) {
      const { Bizplace } = require('@things-factory/biz-base')
      const bizplace = await getRepository(Bizplace).findOne({
        where: {
          name: Raw(alias => `LOWER(${alias}) LIKE '${name.toLowerCase()}'`)
        }
      })
fork icon0
star icon0
watch icon8

+ 31 other calls in file

27
28
29
30
31
32
33
34
35
36

const validators = {
  name: async name => {
    if (/^[a-zA-Z ]+$/.test(name)) {
      const { Domain } = require('@things-factory/shell')
      const domain = await getRepository(Domain).findOne({
        where: [
          {
            name: Raw(alias => `LOWER(${alias}) LIKE '${name.toLowerCase()}'`)
          },
fork icon0
star icon0
watch icon8

+ 47 other calls in file

86
87
88
89
90
91
92
93
94
95
// timezone brasil = 180 
if (timezone != 180) {
    b = 180 - timezone;
    data.setMinutes(data.getMinutes() - b);
}
itemRepo = typeorm_1.getRepository(Item_1.default);
item = itemRepo.create({
    event: evento,
    name: name,
    description: description,
fork icon0
star icon0
watch icon0

+ 14 other calls in file

355
356
357
358
359
360
361
362
363
364
    host = _a.sent();
    eventRepo = typeorm_1.getRepository(Events_1.default);
    return [4 /*yield*/, eventRepo.find({ where: { host: host, id: eventId } })];
case 2:
    evento = _a.sent();
    itemRepo = typeorm_1.getRepository(Items_Comprados_1.default);
    return [4 /*yield*/, itemRepo.find({ where: { event: eventId } })];
case 3:
    items = _a.sent();
    if (!host) {
fork icon0
star icon0
watch icon0

+ 23 other calls in file

4
5
6
7
8
9
10
11
12
13
const Coupons_1 = require("../entity/Coupons");
const coupon_1 = require("../validators/coupon");
const getCoupons = async (req, res) => {
    let code = req.query.code;
    let email = req.query.email;
    let repository = typeorm_1.getRepository(Coupons_1.Coupons);
    if (!code && !email) {
        repository
            .find()
            .then((coupons) => {
fork icon0
star icon0
watch icon0

+ 4 other calls in file

53
54
55
56
57
58
59
60
61
62
63
64


   
})


router.get('/get-product', async function(req, res){
  const productRepository = getRepository(Product);
  const products = await productRepository.find();
  console.log(products);
  res.json(products)
})
fork icon0
star icon0
watch icon0

+ 3 other calls in file