« first day (1874 days earlier)      last day (3089 days later) » 

11:00 PM
Plus the Kraken bottle is badass
Alright, time to go home and pack. I've got to be up at some ungodly hour to get on a plane.
Drink some rum for me. I know I will.
 
It would appear that the Dominican Republic is where good rum comes from
Maybe it will be easier to access in Puerto Rico
rum n stuff
 
release the Kraken!
 
kraken is only 20 bucks for a fifth, it can't be that good?
 
^
 
anyone here worked with Bson documents? I'm not sure how to query one to return a list from it
 
11:08 PM
Sometimes I am better at reading code than English for that type of thing :)
 
ok
well the following returns the whole document including the id, but I only want the countries list from it
countries = collection.Find(new BsonDocument()).ToListAsync().GetAwaiter().GetResult();
oh yeah, the actual model for reference
 
Have you tried looking here? stackoverflow.com/questions/34077614/…
:P j/k
 
lol
nope but that guy sounds like a cool guy
but really, any pointers on how to achieve that?
I know I'm along the right lines so far, of trying to find the list in the returned collection
just not sure how to do it
 
@BrianJ - what is countries type?
 
Country
it's an inner class in the CountryModel class, that stores the name and code for each country in the list
@TravisJ
 
11:18 PM
@BrianJ - hm, hard to tell from my end :(
 
yeah I know it's some operation I need to call on the collection,
everything else seems fine
so at the moment it's doing the below which returns the whole collection
.Find(new BsonDocument()).ToListAsync().GetAwaiter().GetResult();
need to do something like
 
@TravisJ sorry. pretty serious solitaire game going on.
 
collection["countries"].AsList....
 
@Codeman - lol
 
I'll sleep on it, hopefully will have a eureka in the morning
:P
 
11:23 PM
@BrianJ - maybe use as List<Country> ?
or new List<Country>(collection["countires"]) or something similkar
 
yeah this doesn't seem to be correct syntax though
collection["countires"]
says..cannot apply indexing to expression of type..
 
what about just new List<Country>(collection)
 
like this:
countryList = new List<Country>(collection);
Error 11 Argument 1: cannot convert from 'MongoDB.Driver.IMongoCollection<MongoDBApp.Models.CountryModel>' to 'System.Collections.Generic.IEnumerable<MongoDBApp.Models.Country>'
because the returned collection is of type<CountryModel>
 
You cant do a ToList() on the IMongoCollection?
 
user47589
that won't be enough, also need to convert from CountryModel to Country
 
11:30 PM
@BrianJ - I think you need an argument to be passed into the Find method call
hm, I take it back actually
Find is like Where, but you seem to need a projection like Select
 
yeah
 
aha, didnt see that one @Amy. nice catch
:)
 
The Find() is equivelant to Select in MongoDB
 
adios folks, I'm out
 
so I'm thinking it should still be a find, just a different set of paramters
aufwiedersehen
 
11:33 PM
aww I killed my battery
 
anyways, gonna have to come back to this tomorrow
you guys
 
user47589
in robot society, killing batteries is a serious offense.
 
@TravisJ How could I ensure that a value 6351 or 456 or 123 would be converted to 006351 or 000456 or 000123
With JavaScript.
 
non trivially :)
 
I'm having a brain fart.
I was going to do Substring then I was like that doesn't seem smart.
 
user47589
11:41 PM
you can use toLocaleString()
 
user47589
you can also toString() it, prepend "000000" to it, then take the rightmost 6 characters.
 
@Amy That is interesting, but this is more for order numbers.
 
user47589
i assumed the leading 0's in your question meant you wanted strings. is that not so?
 
11:42 PM
@Amy Like:

var curTxtBox = this;
if (this.length < 6) {
curTxtBox.toString('000000');
}
 
I didn't think that would prepend though.
 
user47589
that's an incorrect usage of toString(). in JS, the argument is a radix.
 
@TravisJ I think you have to look at it as an array of arrays
each variable is a column, each row is a system
 
@Greg
function padleft(padding,total,value){
 var inserts = total-(value+"").length;
 padding = padding+"";
 while(inserts--){
   value = padding+value;
 }
 return value;
}
 
11:46 PM
            var curTxtBox = this;
            if (this.length < 6) {
                var formatter = '000000' + curTxtBox;
                curTxtBox = formatter.substring(formatter.length - 6);
            }
 
padleft(0,7,6351) // 0006351
padleft(0,7,123) // 0000123
 
@TravisJ sorry, I'm very distracted. Doing a MongoDB tutorial.
 
@Codeman - all good
 
What about substring, but is that the best way?
Whoa, what is this padding thing I shall take a look.
 
@Greg - scroll up
 
11:48 PM
one last thought on my previous question. I could find all values by "name" and "code" fields, exclude the ID field

http://stackoverflow.com/questions/28296183/get-only-specified-fields-from-mongodb-c-sharp


Then call toList on the returned collection
 
It wrote it
 
user47589
("000000" + 66).slice(-6)
 
user47589
yields "000066"
 
ooh, code golf :D
round 2
 
user47589
Code Golf EXTREME
 
11:55 PM
I like the slice @Amy
 
user47589
as a function:
 
user47589
String.prototype.padLeft = function(width) { return ( "0".repeat(width) + this).slice(-width); }
 
user47589
same thing for Number
 
repeat is es6
 
user47589
oh snap
 
11:58 PM
if you are going to "cheat" with es6 you might as well use the arrow functions ;)
 
user47589
eh, didn't realize it was ES6.
 
we talk about more JS here than the JS room does
 
user47589
you can use a polyfill for it.
 

« first day (1874 days earlier)      last day (3089 days later) »