Progress
This commit is contained in:
@@ -9,6 +9,10 @@ const AppointmentSchema = new Schema({
|
||||
type: String,
|
||||
required: false
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
start: {
|
||||
type: Date,
|
||||
required: true
|
||||
|
||||
@@ -10,10 +10,10 @@ import dotenv from 'dotenv';
|
||||
export const resolvers = {
|
||||
Query: {
|
||||
async allAppointments() {
|
||||
return await Appointment.find();
|
||||
return await Appointment.find({ deleted: false })
|
||||
// return await Appointment.find();
|
||||
},
|
||||
async oneAppointment(root, args, context, info) {
|
||||
console.log(args);
|
||||
return await Appointment.findOne({
|
||||
_id: args._id
|
||||
});
|
||||
@@ -73,6 +73,7 @@ export const resolvers = {
|
||||
},
|
||||
|
||||
async createAppointment(parent, args, context, info) {
|
||||
args.deleted = false;
|
||||
return await Appointment.create(args);
|
||||
},
|
||||
async updateAppointment(parent, args, context, info) {
|
||||
@@ -83,12 +84,8 @@ export const resolvers = {
|
||||
})
|
||||
},
|
||||
async deleteAppointment(parent, args, context, info) {
|
||||
console.log(args);
|
||||
return await Appointment.deleteOne({ _id: args._id }).then(function () {
|
||||
console.log("Data deleted"); // Success
|
||||
}).catch(function (error) {
|
||||
console.log(error); // Failure
|
||||
});
|
||||
return await Appointment.findOneAndUpdate({ _id: args._id }, { deleted: true })
|
||||
// return await Appointment.deleteOne({ _id: args._id });
|
||||
},
|
||||
async createProduct(root, {
|
||||
input
|
||||
|
||||
@@ -17,7 +17,6 @@ function createAppointment(parent, args, context, info) {
|
||||
}
|
||||
|
||||
async function signup(parent, args, context, info) {
|
||||
console.log(context.mongo);
|
||||
const password = await bcrypt.hash(args.password, 10);
|
||||
const user = await context.mongo.user.create({
|
||||
data: { ...args, password }
|
||||
|
||||
@@ -8,7 +8,7 @@ async function feed(parent, args, context, info) {
|
||||
]
|
||||
}
|
||||
: {};
|
||||
console.log(context.mongo);
|
||||
|
||||
const appointments = await context.mongo.appointment.findMany({
|
||||
where,
|
||||
skip: args.skip,
|
||||
|
||||
@@ -24,15 +24,20 @@ type Feed {
|
||||
type Mutation {
|
||||
createAppointment(
|
||||
title: String!
|
||||
description: String!
|
||||
start: String!
|
||||
end: String!
|
||||
description: String
|
||||
type: String!
|
||||
start: DateTime!
|
||||
end: DateTime!
|
||||
deleted: Boolean
|
||||
): Appointment!
|
||||
updateAppointment(
|
||||
_id: ID!,
|
||||
title: String!
|
||||
description: String!
|
||||
start: String!
|
||||
description: String
|
||||
type: String!
|
||||
start: DateTime!
|
||||
end: DateTime!
|
||||
deleted: Boolean
|
||||
): Appointment
|
||||
deleteAppointment(
|
||||
_id: ID!
|
||||
@@ -89,9 +94,10 @@ type AuthPayload {
|
||||
type Appointment {
|
||||
_id: ID!
|
||||
title: String!
|
||||
description: String!
|
||||
start: Time!
|
||||
end: Time!
|
||||
description: String
|
||||
type: String!
|
||||
start: DateTime!
|
||||
end: DateTime!
|
||||
deleted: Boolean
|
||||
# createdBy: User
|
||||
# follows: [Follow!]!
|
||||
@@ -99,14 +105,16 @@ type Appointment {
|
||||
}
|
||||
input AppointmentInput {
|
||||
title: String!
|
||||
description: String!
|
||||
start: Time!
|
||||
end: Time!
|
||||
description: String
|
||||
type: String!
|
||||
start: DateTime!
|
||||
end: DateTime!
|
||||
deleted: Boolean
|
||||
}
|
||||
input AppointmentOrderByInput {
|
||||
description: Sort
|
||||
url: Sort
|
||||
createdAt: Sort
|
||||
title: Sort
|
||||
desc: Sort
|
||||
# createdAt: Sort
|
||||
}
|
||||
|
||||
# Product schemas
|
||||
|
||||
@@ -19,6 +19,9 @@ const connection = mongoose.connect(process.env.MONGODB_URI, {
|
||||
});
|
||||
|
||||
mongoose.set('useCreateIndex', true);
|
||||
mongoose.set('useNewUrlParser', true);
|
||||
mongoose.set('useFindAndModify', false);
|
||||
mongoose.set('useUnifiedTopology', true);
|
||||
|
||||
connection
|
||||
.then(db => db)
|
||||
|
||||
Reference in New Issue
Block a user