【问题标题】:ydn-db join,filter and order byydn-db 加入、过滤和排序
【发布时间】:2014-02-10 09:34:34
【问题描述】:

我有事件和 events_date 对象,想知道如何进行这样的连接查询:

  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'
}

] 
};

【问题讨论】:

标签: ydn-db


【解决方案1】:

我将复制@Risingson 链接的答案。

目前您将不得不使用带有复合索引[objectid, startDate][eventID, startDate]ydn.db.algo.ZigzagMerge,这很难使用。希望(或永远不会)我会完成查询模块,在这种情况下,您只需为任何相等连接编写多个 where 子句。

【讨论】:

    猜你喜欢
    • 2020-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多