@@ -103,7 +103,7 @@ module.exports = (function () {
103
103
return Vogels . define ( collectionName , function ( schema ) {
104
104
//console.log("_getModel", collectionName);
105
105
var columns = global . Hook . models [ collectionName ] . attributes ;
106
- var primaryKey = false ;
106
+ var primaryKeys = [ ]
107
107
var indexes = [ ] ;
108
108
// set columns
109
109
for ( var columnName in columns ) {
@@ -112,21 +112,23 @@ module.exports = (function () {
112
112
// console.log(columnName+":", attributes);
113
113
if ( typeof attributes !== "function" ) {
114
114
adapter . _setColumnType ( schema , columnName , attributes ) ;
115
-
116
115
// search primarykey
117
- if ( ! primaryKey ) {
118
- if ( "primaryKey" in attributes )
119
- primaryKey = columnName ;
120
- }
116
+ if ( "primaryKey" in attributes ) primaryKeys . push ( columnName ) ;
121
117
// search index
122
118
if ( "index" in attributes ) indexes . push ( columnName ) ;
123
119
}
124
120
}
125
121
126
- if ( ! primaryKey )
122
+ if ( primaryKeys . length < 1 )
127
123
schema . UUID ( adapter . keyId , { hashKey : true } ) ;
128
- else
129
- adapter . _setColumnType ( schema , primaryKey , columns [ primaryKey ] , { hashKey : true } ) ;
124
+ else {
125
+ if ( ! require ( "underscore" ) . isUndefined ( primaryKeys [ 0 ] ) ) {
126
+ adapter . _setColumnType ( schema , primaryKeys [ 0 ] , columns [ primaryKeys [ 0 ] ] , { hashKey : true } ) ;
127
+ if ( ! require ( "underscore" ) . isUndefined ( primaryKeys [ 1 ] ) ) {
128
+ adapter . _setColumnType ( schema , primaryKeys [ 1 ] , columns [ primaryKeys [ 1 ] ] , { rangeKey : true } ) ;
129
+ }
130
+ }
131
+ }
130
132
// schema.String( primaryKey, {hashKey: true});
131
133
for ( var i = 0 ; i < indexes . length ; i ++ ) {
132
134
var key = indexes [ i ] ;
0 commit comments