我与自定义属性有多对多关系。来自https://github.com/typeorm/typeorm/blob/master/docs/many-to-many-relations.md 现在,我想获取相关的实体。
如何联接表或关系表的列?
from channels.db import database_sync_to_async
import time
import pymongo
conn = pymongo.MongoClient('xxxx', 27017)
db = conn['test']
async def insert():
time.sleep(1)
print(1111111)
resul =await db.test_collection.insert_many([{'key': "key{}".format(i)} for i in range(10)])
class Index(View):
def get(self, request):
print(2222222)
loop = asyncio.get_event_loop()
loop.run_until_complete(insert)
print(333333333)
return JsonResponse({'1': 111})
数据库
raise NotImplementedError
NotImplementedError
响应应该是
@Entity({name: 'a'})
export class A {
@PrimaryGeneratedColumn()
id: number;
@OneToMany(type => AB, ab => ab.a, )
abs: ab[];
??? // how to get array of B here?
b: B[];
}
@Entity({name: 'b'})
export class B {
@PrimaryGeneratedColumn()
id: number;
@OneToMany(type => AB, ab => ab.b, )
abs: ab[];
}
@Entity()
export class AB {
@PrimaryGeneratedColumn()
id: number;
@Column()
public aId!: number;
@Column()
public bId!: number;
@Column()
public position!: number;
@ManyToOne(type => A, a => a.abs,)
public a!: A;
@ManyToOne(type => B,b => b.abs)
public b!: B;
}