2013-10-14 3 views
0

매우 간단한 문제가 있지만 Breeze로 수행하는 방법을 아직 이해할 수 없습니다. Breeze Query에서 제외 할 ID 배열이 있습니다. SQL에서 수행 할 작업Breeze Query에서 항목을 제거하는 방법

SELECT * 
FROM Items 
WHERE ID NOT IN [...Array...] 

Breeze로 어떻게 처리합니까? 이를 수행 할 운영자가 있습니까? 아니면 수동으로이 작업을 수행 할 수 있습니까?

답변

0

Breeze 쿼리에 여러 조건자를 추가 할 수 있습니다. 이런 식으로 너무 많은 추가 조심, 그러나 이것은 우리가 이것을 할 수있는 방법의 완벽한 예입니다 -

function getAllTodos(todoIds) { 
    var Predicate = breeze.Predicate; 
    var query = breeze.EntityQuery 
      .from("Todos") 
      .orderBy("CreatedAt"); 

    var compoundPredicates; 
    if (todoIds) { 
     var criteriaPredicate; 
     $.each(todoIds(), function(index, item) { 
      criteriaPredicate = (index === 0) 
       ? Predicate.create('todoId', '!=', item) 
       : criteriaPredicate.or('todoId', '!=', item); 
      if (Predicate.isPredicate(criteriaPredicate)) { 
       compoundPredicates = compoundPredicates.and(criteriaPredicate); 
      } 
     } 
    } 
} 

이 화합물이 함께 술어와 ID가없는 경우에는 모든 할 일이야 얻을에 (또는 유사한 무언가)을 수행 할 수 있습니다 배열에있는 값과 같습니다.

관련 문제