카테고리Dev

c# TimeSpan

// timespan to datetime DateTime riderRecord = new DateTime() + record.riderRecord; DateTime riderRecordDifference = new DateTime() + record.riderRecordDifference; DateTime riderRecordSoFar = new DateTime() + record.riderRecordSoFar; // datetime to timespan TimeSpan CurrentTime = riderRecord.TimeOfDay;  

더보기

mongodb unset

db.getCollection(‘contents’).update( {}, { $unset:{ “page”:””, “size”:””, “pub_review” : “”, “contents” : “”, “bookin” : “”, “recommand” : “”, “author_review” : “” } }, {multi:true} )

더보기

c# serialize

var pipeline = new[] { match, unwind, lookup, project, group }; AggregateResult result = collection.Aggregate(pipeline); var aggregate = result.Response.GetValue(0); var aggregateArr = aggregate.AsBsonArray; fpOrderItem.ActiveSheet.Rows.Count = 0; int ttt = 0; foreach (var agg_result in aggregateArr) { var order_record = agg_result[“_id”]; var order_no = order_record[“order_no”].ToString(); var order_list_str = order_record[“order_list”]; var contents_str ...

더보기

mongodb join

db.order_list.aggregate([ { $unwind: “$booklist” }, { $lookup: { from: “contents”, localField: “booklist.isbn”, foreignField: “isbn”, as: “xxxx” } }, { $group:{ _id:{order_no:”$order_no”}, booklist:{ $push:”$xxxx.isbn”, $push:”$xxxx.title” } } } ])   ======================================     db.votes.aggregate([ { $lookup: { from: “users”, localField: “createdBy”, foreignField: “_id”, as: “userYYY” } }, { $unwind: “$userYYY” }, ...

더보기

mongoDB serialize

  public class Zoo { [BsonId] public ObjectId Id { get; set; } public List<Animal> Animals { get; set; } } [BsonDiscriminator(RootClass = true)] [BsonKnownTypes(typeof(Tiger), typeof(Zebra))] public class Animal { [BsonId] public ObjectId Id { get; set; } public string Name { get; set; } } public class Tiger : ...

더보기

Storing TreeView Structures With MongoDB

Storing Tree like Structures With MongoDB Educational repository demonstrating approaches for storing tree structures with NoSQL database MongoDB Background In a real life almost any project deals with the tree structures. Different kinds of taxonomies, site structures etc require modelling of hierarhy relations. In this article I will illustrate using ...

더보기

mongodb recursive

db.files.save({ _id: "root"}) db.files.save({ _id: "src", parent: "root", ancestors: ["root"] } ) db.files.save({ _id: "lib", parent: "root", ancestors: ["root"]} ) db.files.save({ _id: "config.cfg", parent: "root", ancestors: ["root"], size: 2310 }) db.files.save({ _id: "file1.js", parent: "src", ancestors: ["root","src"], size: 5039 }) db.files.save({ _id: "file2.js", parent: "src", ancestors: ["root","src"], size: 1299 }) ...

더보기

mongodb timezone

mongodb에 저장 될때는 무조건 UTC 시간으로 저장된다. 검색할때 db.getCollection(‘contents’).find( {“update”:{$elemMatch:{“type”:”update”, “date”:{ $gte:ISODate(“2018-10-18T00:00:00+0900”), $lt:ISODate(“2018-10-19T00:00:00+0900”) } }}}, {cid:1,update:1} )

더보기

This is a unique website which will require a more modern browser to work!

Please upgrade today!