Guest User

Untitled

a guest
Nov 2nd, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. create(budgetProps){
  2. const budget = new Budget(budgetProps);
  3. return budget.save();
  4. }
  5.  
  6. {
  7. "data": {
  8. "addBudget": {
  9. "_id": "59fbdefaa7b0a81180dd2c9c",
  10. "tiempoAproximado": 2245.5,
  11. "User": {
  12. "name": null,
  13. "organization": null
  14. },
  15. "Vehicle": {
  16. "name": null,
  17. "type": null
  18. }
  19. }
  20. }
  21. }
  22.  
  23. create(budgetProps){
  24. const budget = new Budget(budgetProps);
  25. return budget.save().then((res)=>{
  26. Budget.findById(res._id)
  27. .populate('User')
  28. .populate('Vehicle')
  29. .exec((err, newBudget)=> {
  30. return newBudget;
  31. });
  32. });
  33. },
  34.  
  35. {
  36. "data": {
  37. "addBudget": null
  38. }
  39. }
  40.  
  41. const typeDefs = `
  42. scalar Date
  43.  
  44. input UserInput {
  45. _id: ID,
  46. name: String,
  47. organization: String,
  48. phones: [String],
  49. emails: [String],
  50. type: String,
  51. password: String,
  52. percentaje: String
  53. }
  54.  
  55. input VehicleDescriptionInput {
  56. es: String,
  57. en: String
  58. }
  59.  
  60. input VehicleInput{
  61. _id: ID,
  62. name: String,
  63. passengers: Int,
  64. largeBags: Int,
  65. smallBags: Int,
  66. doors: Int,
  67. type: String,
  68. status: Boolean,
  69. imagesUrls: [String],
  70. description: VehicleDescriptionInput
  71. }
  72.  
  73. input FinalTotalCostInput {
  74. es: String,
  75. en: String
  76. }
  77.  
  78. input BudgetTotalCostInput {
  79. es: String,
  80. en: String
  81. }
  82.  
  83. input BudgetInput {
  84. finalTotalCost: FinalTotalCostInput,
  85. budgetTotalCost: BudgetTotalCostInput,
  86. destinoInicial: String,
  87. destinoFinal: String,
  88. tiempoAproximado: Float,
  89. distancia: Float,
  90. tollCost: Float,
  91. tolls: [String],
  92. budgetDate: Date,
  93. aprove: Boolean,
  94. User: UserInput,
  95. Vehicle: VehicleInput
  96. }
  97.  
  98. type Mutation {
  99. addBudget(data: BudgetInput): Budget
  100. }
  101. `;
  102.  
  103. Mutation: {
  104. addBudget: (_, {data}) =>{
  105. return BudgetController.create(data);
  106. }
  107. },
  108.  
  109. mutation addBudget($budget: BudgetInput) {
  110. addBudget(data: $budget) {
  111. _id
  112. User{
  113. name
  114. organization
  115. }
  116. Vehicle{
  117. name
  118. type
  119. }
  120. }
  121. }
  122.  
  123. {
  124. "budget": {
  125. "finalTotalCost": {
  126. "es": "100 peso",
  127. "en": "10 dolars"
  128. },
  129. "budgetTotalCost": {
  130. "es": "80 peso",
  131. "en": "8 dolars"
  132. },
  133. "destinoInicial": "Queretaro",
  134. "destinoFinal": "Sonora",
  135. "tiempoAproximado": 2245.5,
  136. "distancia": 100.565,
  137. "tollCost": 20.5,
  138. "tolls": [
  139. "GDL",
  140. "Marina",
  141. "Culap",
  142. "Malageña"
  143. ],
  144. "budgetDate": "2017/07/21",
  145. "aprove": false,
  146. "User": {
  147. "_id": "59fbcc42aa82460924e5fbad"
  148. },
  149. "Vehicle": {
  150. "_id": "59fbcbe4aa82460924e5fbac"
  151. }
  152. }
  153. }
Add Comment
Please, Sign In to add comment