1

我有事件和 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'
}

] 
};
4

1 回答 1

0

I will copy answer as linked by @Risingson.

Currently you will have to use ydn.db.algo.ZigzagMerge with compound indexes [objectid, startDate], [eventID, startDate], which is very difficult to use. Hopefully (or never) I will finish query module, in that case you just write multiple where clause for any equal join.

于 2014-02-16T04:27:30.827 回答