Exemple #1
0
        public async Task Post(Comment comment)
        {
            try {
                BsonObjectId oldId = new BsonObjectId(new ObjectId(comment.id.ToString()));
                var          temp  = oldId.GetType();
                temp.GetType();
                var mongoDbClient = new MongoClient("mongodb://127.0.0.1:27017");
                var mongoDbServer = mongoDbClient.GetDatabase("nmbp");
                var collection    = mongoDbServer.GetCollection <PostInfo>("post");

                var filter = Builders <PostInfo> .Filter.Eq("_id", oldId);

                var update = Builders <PostInfo> .Update.Push("post_comments", comment.comment);

                await collection.FindOneAndUpdateAsync(filter, update);

                var test = oldId.GetType();
            }
            catch
            {
                var yolo = "you only live once";
                yolo.GetType();
            }
        }
        public async Task Post(Comment comment)
        {
            try {
                BsonObjectId oldId = new BsonObjectId(new ObjectId(comment.id.ToString()));
                var temp = oldId.GetType();
                temp.GetType();
                var mongoDbClient = new MongoClient("mongodb://127.0.0.1:27017");
                var mongoDbServer = mongoDbClient.GetDatabase("nmbp");
                var collection = mongoDbServer.GetCollection<PostInfo>("post");

                var filter = Builders<PostInfo>.Filter.Eq("_id", oldId);
                var update = Builders<PostInfo>.Update.Push("post_comments", comment.comment);
                await collection.FindOneAndUpdateAsync(filter, update);
                var test = oldId.GetType();
            }
            catch
            {
                var yolo = "you only live once";
                yolo.GetType();
            }
        }