context.simple.fixture.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var structure = require('./context.fixture');
  2. /**
  3. * Context Fixture for a Belongs To Relationship
  4. */
  5. module.exports = function() {
  6. var context = structure;
  7. // Name the collection
  8. context.identity = 'foo';
  9. context.primaryKey = 'id';
  10. // Set collection attributes
  11. context._attributes = {
  12. id: {
  13. type: 'integer',
  14. autoIncrement: true,
  15. primaryKey: true,
  16. unique: true
  17. },
  18. name: { type: 'string' }
  19. };
  20. // Build a mock global schema object
  21. context.waterline.schema = {
  22. foo: {
  23. identity: 'foo',
  24. attributes: {
  25. name: 'string',
  26. id: {
  27. type: 'integer',
  28. autoIncrement: true,
  29. primaryKey: true,
  30. unique: true
  31. }
  32. }
  33. },
  34. bar: {
  35. identity: 'bar',
  36. attributes: {
  37. name: 'string',
  38. id: {
  39. type: 'integer',
  40. autoIncrement: true,
  41. primaryKey: true,
  42. unique: true
  43. }
  44. }
  45. }
  46. };
  47. // Build global collections
  48. context.waterline.collections.foo = {
  49. identity: 'foo',
  50. _attributes: context._attributes
  51. };
  52. context.waterline.collections.bar = {
  53. identity: 'bar',
  54. _attributes: {
  55. name: { type: 'string' },
  56. id: {
  57. type: 'integer',
  58. autoIncrement: true,
  59. primaryKey: true,
  60. unique: true
  61. }
  62. }
  63. };
  64. return context;
  65. };