- a user can be part of multiple org
- a user can be logged on the multiple dashboard at the same time
- a user can be logged on the multiple dashboard of different org at the same time
return all users, who are logged in the given dashboard,who belongs to the given org.
const LiveUserSchema = new mongoose.Schema({
users: {
type: [{
name:String,
email:String // this should be unique in this array
}],
default: []
}
})
Initially i have the data
{
users:[
{name:"..",email:"123"},
{name:"..",email:"789"}
]
}
Now, i would like to push a user with email 012
, he should be pushed into the array because, it's not there already.
Then new data will looks like
{
users:[
{name:"..",email:"123"},
{name:"..",email:"789"},
{name:"..",email:"012"}
]
}
Now, i would like to push a user with email 123
, he should not be pushed into the array because, it's already there.
new data
// no change
{
users:[
{name:"..",email:"123"},
{name:"..",email:"789"},
{name:"..",email:"012"}
]
}
Schema - 1
add support, if the
org
already dose't exist inside the collectionadd support, if the
user
is not persent insideusers
arrayremove the dashboard from
dashboards
when user disconnectsadd dashboard into
dashboards
when user connects