Click here to Skip to main content
15,879,326 members
Home / Discussions / Database
   

Database

 
AnswerRe: Given two dates, count the number of dates in the range that is within month X Pin
Craig Robbins13-Apr-22 4:10
Craig Robbins13-Apr-22 4:10 
AnswerRe: Given two dates, count the number of dates in the range that is within month X Pin
CHill6020-Apr-22 7:04
mveCHill6020-Apr-22 7:04 
QuestionBest practice for creating a limited access ms-sql user ? Pin
David Mujica12-Apr-22 11:12
David Mujica12-Apr-22 11:12 
AnswerRe: Best practice for creating a limited access ms-sql user ? Pin
jschell8-May-22 8:11
jschell8-May-22 8:11 
QuestionMysql How to sort row ORDER BY another query? Pin
Zac Ang3-Apr-22 10:45
Zac Ang3-Apr-22 10:45 
SuggestionRe: Mysql How to sort row ORDER BY another query? Pin
Richard Deeming3-Apr-22 21:46
mveRichard Deeming3-Apr-22 21:46 
AnswerRe: Mysql How to sort row ORDER BY another query? Pin
CHill606-Apr-22 2:57
mveCHill606-Apr-22 2:57 
QuestionFilter data before lookup(join) two collections in mongodb Pin
85510-Mar-22 4:20
85510-Mar-22 4:20 
I'm writing a function which will join two collections and two filters for each.
C#
public class Teacher
{
        public string Id{ get; set; }
        public string Name{ get; set; }
        public string TeacherFilter{ get; set; }
        ...
}

public class Student
{
        public string Id{ get; set; }
        public string Name{ get; set; }
        public string StudentFilter{ get; set; }
        public string TeacherId{ get; set; }
        ...
}

public class TeacherStudents
{
        public string Id{ get; set; } -- from teacher
        public string Name{ get; set; } -- from teacher
        public IEnumerable<Student> Students{get;set;}
}

public class TeacherStudents
{
        public string Id{ get; set; } -- from teacher
        public string Name{ get; set; } -- from teacher
        public IEnumerable<Student> Student{get;set;}
}

public class TeacherStudent
{
        public string Id{ get; set; } -- from teacher
        public string Name{ get; set; } -- from teacher
        ...
        public Student Student{get;set;}
}

Get(string TeacherFilter,string StudentFilter).


Here is how i implement it
var query = teacherCollection.Aggregate().Match(x => x.TeacherFilter== TeacherFilter); //filter teach
var query1 = query
.Lookup<Teacher, Student, TeacherStudent>(studentCollection, t => t.Id, s => s.TeacherId, l => l.Student)
.Unwind(x => x.Student, new AggregateUnwindOptions<TeacherStudent>())
.Match(x => x.StudentFilter== StudentFilter) //filter student   

For the teacher collection, useless data has been filter out which will reduce the data size when doing the lookup(join). But for the student collection, the match stage is appended after the lookup. so does all the data from student will join with teacher behind the scenes? is it possible to filter out some student data before the lookup?
Rant[REPOST] Filter data before lookup(join) two collections in mongodb Pin
Richard Deeming10-Mar-22 4:51
mveRichard Deeming10-Mar-22 4:51 
GeneralRe: [REPOST] Filter data before lookup(join) two collections in mongodb Pin
85510-Mar-22 5:23
85510-Mar-22 5:23 
GeneralRe: [REPOST] Filter data before lookup(join) two collections in mongodb Pin
Richard Deeming10-Mar-22 6:26
mveRichard Deeming10-Mar-22 6:26 
Question[MySQL] Failed to set datadir Pin
chipp_zanuff1-Mar-22 7:54
chipp_zanuff1-Mar-22 7:54 
AnswerRe: [MySQL] Failed to set datadir Pin
Victor Nijegorodov1-Mar-22 8:39
Victor Nijegorodov1-Mar-22 8:39 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff1-Mar-22 17:42
chipp_zanuff1-Mar-22 17:42 
GeneralRe: [MySQL] Failed to set datadir Pin
Victor Nijegorodov1-Mar-22 22:42
Victor Nijegorodov1-Mar-22 22:42 
AnswerRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan1-Mar-22 22:45
mveRichard MacCutchan1-Mar-22 22:45 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff2-Mar-22 0:35
chipp_zanuff2-Mar-22 0:35 
GeneralRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan2-Mar-22 0:47
mveRichard MacCutchan2-Mar-22 0:47 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff2-Mar-22 23:37
chipp_zanuff2-Mar-22 23:37 
GeneralRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan2-Mar-22 23:44
mveRichard MacCutchan2-Mar-22 23:44 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff3-Mar-22 0:30
chipp_zanuff3-Mar-22 0:30 
GeneralRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan3-Mar-22 0:46
mveRichard MacCutchan3-Mar-22 0:46 
QuestionDetach database in SQL Server Pin
Meysam Toluie17-Feb-22 4:44
Meysam Toluie17-Feb-22 4:44 
QuestionWorks in MYSQL 5.7, Syntax Error in MYSQL 8.0 Pin
Douglas Kirk 202216-Feb-22 2:36
Douglas Kirk 202216-Feb-22 2:36 
AnswerRe: Works in MYSQL 5.7, Syntax Error in MYSQL 8.0 Pin
jschell17-Feb-22 11:37
jschell17-Feb-22 11:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.