These are chat archives for Automattic/mongoose

29th
Aug 2016
temuccio
@temuccio
Aug 29 2016 06:23
Hello All
I make a system of search, and for this problem I create a dynamic query
Now I create this query as string...
It is possible to convert the string to query?
This is the code of creation:
var formato=".where('formato')";
        var supporto=".where('supporto')";
        var colore=".where('colore')";
        var fronte_retro=".where('fronte_retro')";
        var rilegatura=".where('rilegatura')";
        var copertina=".where('copertina')";
        var query = database.Utente.find();
        if (values.length == 1){
            formato=formato+'.equals('+values[i].formato+')';
            supporto=supporto+'.equals('+values[i].supporto+')';
            colore=colore+'.equals('+values[i].colore+')';
            fronte_retro=fronte_retro+'.equals('+values[i].fronte_retro+')';
            rilegatura=rilegatura+'.equals('+values[i].rilegatura+')';
            copertina=copertina+'.equals('+values[i].copertina+')';
        }
        else{
            for (var i=0; i<values.length; i++){
                formato=formato+'.and('+values[i].formato+')';
                supporto=supporto+'.and('+values[i].supporto+')';
                colore=colore+'.and('+values[i].colore+')';
                fronte_retro=fronte_retro+'.and('+values[i].fronte_retro+')';
                rilegatura=rilegatura+'.and('+values[i].rilegatura+')';
                copertina=copertina+'.and('+values[i].copertina+')';
            }
            console.log(formato);
            console.log(supporto);
            console.log(colore);
            console.log(fronte_retro);
            console.log(rilegatura);
            console.log(copertina);
        }
And this is a simulation of output
.where('formato').and(A4).and(A4)
.where('supporto').and(80_90).and(80_90)
.where('colore').and(false).and(false)
.where('fronte_retro').and(true).and(true)
.where('rilegatura').and(liberi).and(liberi)
.where('copertina').and(true).and(false)
temuccio
@temuccio
Aug 29 2016 06:35
I can add object query on every first line?
Nishchit
@Nishchit14
Aug 29 2016 12:56
Hello friends,
Here is test output dashboard for mongoose
https://vigoreport.io/p/MUO9eVz
Is this helpful to devs ?
Suraj Kamath
@surajkamath4sk
Aug 29 2016 13:31
Hi all
Can anyone mail me 'Brochure on Internet Of Things, alone for Malls and Hospitals' PDF or PPT ..
Please its urgent :worried:
Thanks
surajkamath4sk@yahoo.com
Jonathan
@MaddoxDevelopment
Aug 29 2016 18:28
is there a way to query for something and ignore the case with mongoose? Right now when i search ‘Dog’ for example, it will only show ‘Dog’ and not ‘dog’.
LeonineKing1199
@LeonineKing1199
Aug 29 2016 18:41
You can search by regexes but your queries become hella slow.
If you want Dog and dog in the same query, you can use the $or operator.
Jonathan
@MaddoxDevelopment
Aug 29 2016 18:42
yeah or might be the best choice here
rather not slow it down with regex
thanks
LeonineKing1199
@LeonineKing1199
Aug 29 2016 18:43
Managing a document store can be kind of a mess.
We've started writing one-time-use scripts that update our database as need be.
In your case, it might be easier to do this and update everything to either be all lower case or all upper case.
Jonathan
@MaddoxDevelopment
Aug 29 2016 18:44
yeah, that could also work, I may just store a lower case field of everything to compare to
well only for important things that two people can’t have the same