Ho letto this page ma non ha ottenuto quando usare funzione incorporamento e quando utilizzare linking.I avere un progetto in Django per il quale sto usando MongoDB.In mio file models.py devo seguenti modelli:Incorporamento Vs Collegamento in MongoDB.quando inserire e quando collegare?
class Projects(models.Model):
projectName =models.CharField(max_length = 100,unique=True,db_index=True)
projectManager = EmbeddedModelField('Users')
class Teams(models.Model):
teamType = models.CharField(max_length =100)
teamLeader = EmbeddedModelField('Users')
teamProject = EmbeddedModelField('Projects')
objects = MongoDBManager()
class Users(models.Model):
name = models.CharField(max_length = 100,unique=True)
designation = models.CharField(max_length =100)
teams = ListField(EmbeddedModelField('Teams'))
class Tasks(models.Model):
title = models.CharField(max_length = 150)
description = models.CharField(max_length=1000)
priority = models.CharField(max_length=20)
Status = models.CharField(max_length=20)
assigned_to = EmbeddedModelField('Users')
assigned_by = EmbeddedModelField('Users')
child_tasks = ListField()
parent_task = models.CharField(max_length = 150)
La mia domanda è se facciamo l'incorporamento dobbiamo aggiornare l'oggetto in tutti i modelli. Se desidero aggiornare il nome di un 'utente', dovrei eseguire l'aggiornamento per i modelli: progetti, team, utenti e attività o il collegamento sarebbe migliore nel mio caso?
puoi mostrarmi un esempio? ti sarei grato :) – Anshul
Sostituisci semplicemente tutti i tuoi EmbeddedModelField ('Utenti') con un ReferenceField ('Utenti'). – hymloth
Ma sto usando il motore Django-mongoDB e non ha campo come ReferenceField. :( – Anshul