如何更新结构复杂的Mongo DB文档

时间:2016-03-12 20:19:53

标签: java mongodb

我有一个具有以下结构的mongoDB文档

ArrayList

我想为id = 2的Feed(上面标有**字段)更新pay == true。如何使用mongo java客户端?

我试过了

ArrayList

1 个答案:

答案 0 :(得分:1)

class FAPhoto: UIViewController, UIScrollViewDelegate { var imageURLsArray = [String]() var imageViews:[UIImageView] = [] var arrayOfPhotos = [Photo]() var scrollView = UIScrollView() override func viewDidLoad() { super.viewDidLoad() scrollView = UIScrollView(frame: self.view.frame) view.addSubview(scrollView) scrollView.contentSize = CGSizeMake(view.frame.size.width * CGFloat(arrayOfPhotos.count), scrollView.frame.size.height) scrollView.pagingEnabled = true for (var i = 0; i < arrayOfPhotos.count; i++) { var imageView = UIImageView() imageView.frame = CGRectMake(CGFloat(i) * view.frame.size.width, scrollView.frame.origin.y, scrollView.frame.size.width, scrollView.frame.size.height) imageView.contentMode = .ScaleAspectFit let image = imageView.hnk_setImageFromURL(NSURL(string: arrayOfPhotos[i].url!)!) scrollView.addSubview(imageView) } } override func viewWillAppear(animated: Bool) { } override func viewWillLayoutSubviews() { let bindings = Dictionary(dictionaryLiteral: ("scrollView", self.scrollView)) let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( "H:|-0-[scrollView]-0-|", options: [], metrics: nil, views: bindings) self.view.addConstraints(horizontalConstraints) let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( "V:|-0-[scrollView]-0-|", options: [], metrics: nil, views: bindings) self.view.addConstraints(verticalConstraints) } } 是一个数组,您正在更新第二个元素,因此Feeds将以:

结尾
set

而不是:

.append("Feeds.1.paid", "true"));