2014-02-10 52 views
1

我有要事和events_date對象,想知道如何做一個像這樣的連接查詢:YDN-DB加入,過濾器和order by

select * 
    from events, events_dates 
    where events.objectid=event_dates.eventID 
    order by event_dates.startDate asc 

這裏是我的架構。我已經包含了這個,所以你可以看到簡單的這是,但是做使用YDN-DB API聯接是非常困難的:

var events_schema = { 
name:   'events', 
keyPath:  'objectid', 
type:   'TEXT', 
autoIncrement: false, 
indexes: [ 
{ 
    keyPath: 'eventName' 
    }, { 
    keyPath: 'contactPerson' 
}, { 
    keyPath: 'contactPersonEmail' 
}, { 
    keyPath: 'contactPersonCell' 
}, { 
    keyPath: 'eventURL' 
}, { 
    keyPath: 'city' 
}, { 
    keyPath: 'address' 
}, { 
    keyPath: 'parishStateProvince' 
}, { 
    keyPath: 'country' 
}, { 
    keyPath: 'isFeatured' 
}, { 
    keyPath: 'shortDescription' 
}, { 
    keyPath: 'salesCutOffHour' 
}, { 
    keyPath: 'venu' 
}, { 
    keyPath: 'longDescription' 
}, { 
    keyPath: 'createdAt' 
} 

] 
}; 


var events_dates_schema = { 
name:   'event_dates', 
keyPath:  'objectid', 
type:   'TEXT', 
autoIncrement: false, 
indexes: [ 
{ 
    keyPath: 'eventID' 
}, { 
    keyPath: 'deliveryMethodMobile' 
}, { 
    keyPath: 'deliveryMethodWillCall' 
}, { 
    keyPath: 'endDate' 
}, { 
    keyPath: 'endAmPm' 
}, { 
    keyPath: 'maxAvailableTickets' 
}, { 
    keyPath: 'salesCutOffHour' 
}, { 
    keyPath: 'startAmPm' 
}, { 
    keyPath: 'startDate' 
} 

] 
}; 
+0

http://stackoverflow.com/questions/21515180/most-efficient-way-to-query-ydn-db-in-a-joining-way – Risingson

回答

0

由@Risingson鏈接我會複製答案。

目前您將不得不使用ydn.db.algo.ZigzagMerge複合索引[objectid, startDate][eventID, startDate],這是非常難以使用。希望(或從不)我會完成查詢模塊,在這種情況下,您只需爲任何等於連接寫入多個where子句。