Skip to content

Commit 1adbb16

Browse files
committed
Move index creation to Sapling proper, remove unnecessary in logic for now
1 parent 502e87f commit 1adbb16

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

index.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,7 @@ module.exports = class Mongo extends Interface {
103103

104104
const self = this;
105105

106-
const collection = await this.database.createCollection(name, mongo_options.open, () => {
107-
/* Go through all the fields in the model */
108-
for (const key in fields) {
109-
const rule = fields[key];
110-
111-
/* Create indices for any fields marked unique or identifiable */
112-
/* TODO: move this to Sapling proper, so we don't rely on drivers to implement model rule logic */
113-
if (rule.unique || rule.identifiable) {
114-
const ufields = {};
115-
ufields[key] = 1;
116-
self.createIndex(name, ufields, {unique: true});
117-
}
118-
}
119-
});
106+
const collection = await this.database.createCollection(name, mongo_options.open);
120107

121108
await this.close();
122109

@@ -163,23 +150,6 @@ module.exports = class Mongo extends Interface {
163150
/* If there is an _id field in constraints, create a proper object ID object */
164151
conditions = this.convertObjectId(conditions);
165152

166-
/* TODO: find out what this is */
167-
if (options['in']) {
168-
const inOpts = options['in'];
169-
const key = Object.keys(inOpts)[0];
170-
171-
if (key == '_id') { // TODO: include keys with rule.type == id
172-
for (let i = 0; i < inOpts[key].length; ++i) {
173-
try {
174-
inOpts[key][i] = mongo.ObjectID(inOpts[key][i])
175-
} catch (e) {}
176-
}
177-
}
178-
179-
conditions[key] = {'$in': inOpts[key]};
180-
options = {};
181-
}
182-
183153
/* Get the collection */
184154
const collection = await this.database.collection(name, mongo_options.collection);
185155

0 commit comments

Comments
 (0)