chore: test (#2677)
This commit is contained in:
parent
fc609bafb9
commit
91095d8fe0
@ -13,6 +13,39 @@ describe('belongs to many field', () => {
|
|||||||
await db.close();
|
await db.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should define belongs to many relation through exists pivot collection', async () => {
|
||||||
|
const PostTag = db.collection({
|
||||||
|
name: 'postsTags',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'bigInt',
|
||||||
|
name: 'id',
|
||||||
|
primaryKey: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(PostTag.model.rawAttributes['id']).toBeDefined();
|
||||||
|
|
||||||
|
const Tag = db.collection({
|
||||||
|
name: 'tags',
|
||||||
|
fields: [
|
||||||
|
{ type: 'string', name: 'name' },
|
||||||
|
{ type: 'belongsToMany', name: 'posts', through: 'postsTags' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const Post = db.collection({
|
||||||
|
name: 'posts',
|
||||||
|
fields: [
|
||||||
|
{ type: 'string', name: 'name' },
|
||||||
|
{ type: 'belongsToMany', name: 'tags', through: 'postsTags' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(PostTag.model.rawAttributes['id']).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
test('association undefined', async () => {
|
test('association undefined', async () => {
|
||||||
const Post = db.collection({
|
const Post = db.collection({
|
||||||
name: 'posts',
|
name: 'posts',
|
||||||
|
Loading…
Reference in New Issue
Block a user