Skip to content

Commit

Permalink
Make realKeys available on Mongoose field adapters (#2585)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Mar 26, 2020
1 parent 63e2519 commit e7e4bc1
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-fireants-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/fields': patch
---

Internal refactor, no functional changes.
8 changes: 2 additions & 6 deletions docs/guides/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ class CustomApp {

module.exports = {
keystone,
apps: [
new GraphQLApp(),
new AdminUIApp(),
new CustomApp(),
]
}
apps: [new GraphQLApp(), new AdminUIApp(), new CustomApp()],
};
```
4 changes: 2 additions & 2 deletions docs/guides/custom-mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ If we had a front-end application that updated the view count every time someone
Using CRUD we'd first have to fetch the current view count:

```graphql
query Page($id: ID!){
Page(where:{id: $id}) {
query Page($id: ID!) {
Page(where: { id: $id }) {
views
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/initial-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ For example:
keystone.createItems({
User: [
{ name: 'John Duck', email: 'john@duck.com', password: 'dolphins' },
{ name: 'Barry', email: 'bartduisters@bartduisters.com', password: 'dolphins' }
{ name: 'Barry', email: 'bartduisters@bartduisters.com', password: 'dolphins' },
],
});
```
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/new-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ In `index.js` add the following above `module.exports` and below `const keystone
keystone.createList('Todo', {
fields: {
name: { type: Text },
}
},
});
```

Expand Down
1 change: 1 addition & 0 deletions packages/auth-password/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const authStrategy = keystone.createAuthStrategy({
},
});
```

**Note:** The auth strategy must be created after the User list.

Later, the admin UI authentication handler will do something like this:
Expand Down
14 changes: 7 additions & 7 deletions packages/fields/src/types/DateTime/Implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,21 @@ const CommonDateTimeInterface = superclass =>
export class MongoDateTimeInterface extends CommonDateTimeInterface(MongooseFieldAdapter) {
constructor() {
super(...arguments);
this.dbPath = `${this.path}_utc`;
this.utcPath = `${this.path}_utc`;
this.offsetPath = `${this.path}_offset`;
this.realKeys = [this.utcPath, this.offsetPath];
this.dbPath = this.utcPath;
}

addToMongooseSchema(schema) {
const { mongooseOptions } = this.config;
const field_path = this.path;
const utc_field = `${field_path}_utc`;
const offset_field = `${field_path}_offset`;
schema.add({
// FIXME: Mongoose needs to know about this field in order for the correct
// attributes to make it through to the pre-hooks.
[field_path]: { type: String, ...mongooseOptions },
[this.path]: { type: String, ...mongooseOptions },
// These are the actual fields we care about storing in the database.
[utc_field]: { type: Date, ...mongooseOptions },
[offset_field]: { type: String, ...mongooseOptions },
[this.utcPath]: { type: Date, ...mongooseOptions },
[this.offsetPath]: { type: String, ...mongooseOptions },
});
}

Expand Down
4 changes: 4 additions & 0 deletions packages/fields/src/types/Virtual/Implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const CommonTextInterface = superclass =>
};

export class MongoVirtualInterface extends CommonTextInterface(MongooseFieldAdapter) {
constructor() {
super(...arguments);
this.realKeys = [];
}
addToMongooseSchema() {}
}

Expand Down

0 comments on commit e7e4bc1

Please sign in to comment.