使用Mongo模板在MongoDB中查询嵌入式文档

时间:2017-09-30 14:05:29

标签: mongodb mongodb-query aggregation-framework spring-mongodb mongotemplate

我有上述域名结构,我在产品中列出了公司列表,当我与公司完全匹配时,我们的目标不是进入mongoDB。 var myModule = angular.module('BlankApp', ['ngMaterial']); myModule.controller("FilterCtrl", function($scope, $element) { $scope.categories = ["Any", "None", "Option 1", "Option 2", "Option 3", "Option 4"]; $scope.mustCatSelected = []; $scope.categoryObj = {}; $scope.categoryObj.items = []; $scope.categories.forEach(function(value,key){ var grp; if (key < 2){grp = key;} if (key >= 2){grp = 2;} $scope.categoryObj.items.push({ name: value, id: (key + 1), group: grp}); }); //set default $scope.mustCatSelected.push($scope.categoryObj.items[0]); $scope.clickOn = clickOn; function clickOn(newValue, oldValue, type) { //console.log($scope.categoryObj.items); //console.log(oldValue); if(oldValue.length == 0) { return false; } //create arrays of new and old option ids oldValue = JSON.parse(oldValue); var newIds = []; var oldIds = []; newValue.forEach(function(value,key){ newIds.push(value.id); }); oldValue.forEach(function(value,key){ oldIds.push(value.id); }); //define and set the clicked value var clickedValue; newIds.forEach(function(value, key){ if(oldIds.indexOf(value) == -1) { clickedValue = value; } }); var clickedGroup; newValue.forEach(function(value,key){ if(value.id == clickedValue){ clickedGroup = value.group; } }); //console.log([clickedValue, clickedGroup]); //console.log([newIds, oldIds, clickedValue]); if(type == 'mustCat'){ $scope.mustCatSelected = $scope.mustCatSelected.filter(function(e){ return e.group == clickedGroup; }); } } //search term above select $scope.searchTerm; $scope.clearSearchTerm = function() { $scope.searchTerm = ''; }; // The md-select directive eats keydown events for some quick select // logic. Since we have a search input here, we don't need that logic. $element.find('input').on('keydown', function(ev) { ev.stopPropagation(); }); }); 已存在于数据库中。

productId

我正在使用mongo模板,我尝试使用如下所示的find但是id没有工作

@Entity
    public class Mobile {
        @Id
        private Integer id;
        private String imei;
        private Product productInfo;

        // ...
    }


    @Entity
    public class Product {
        @Id
        private Integer id;
        private String productId;
        private List<Company<?>> companies;

        // ...
    }


    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME,
        include = JsonTypeInfo.As.PROPERTY, property = "type")
    @JsonSubTypes({
        @JsonSubTypes.Type(name= "samsung", value = Samsung.class),
        @JsonSubTypes.Type(name= "htc",value = Htc.class)})
    public class Company<T> implements Serializable {
        private static final long serialVersionUID = -8869676577723436716L;

        private T companyInfo;
        private String type;

        // ...
    }

0 个答案:

没有答案