FLEXSQLResult.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // FLEXSQLResult.h
  3. // FLEX
  4. //
  5. // Created by Tanner on 3/3/20.
  6. // Copyright © 2020 FLEX Team. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @interface FLEXSQLResult : NSObject
  11. /// Describes the result of a non-select query, or an error of any kind of query
  12. + (instancetype)message:(NSString *)message;
  13. /// Describes the result of a known failed execution
  14. + (instancetype)error:(NSString *)message;
  15. /// @param rowData A list of rows, where each element in the row
  16. /// corresponds to the column given in /c columnNames
  17. + (instancetype)columns:(NSArray<NSString *> *)columnNames
  18. rows:(NSArray<NSArray<NSString *> *> *)rowData;
  19. @property (nonatomic, readonly, nullable) NSString *message;
  20. /// A value of YES means this is surely an error,
  21. /// but it still might be an error even with a value of NO
  22. @property (nonatomic, readonly) BOOL isError;
  23. /// A list of column names
  24. @property (nonatomic, readonly, nullable) NSArray<NSString *> *columns;
  25. /// A list of rows, where each element in the row corresponds
  26. /// to the value of the column at the same index in \c columns.
  27. ///
  28. /// That is, given a row, looping over the contents of the row and
  29. /// the contents of \c columns will give you key-value pairs of
  30. /// column names to column values for that row.
  31. @property (nonatomic, readonly, nullable) NSArray<NSArray<NSString *> *> *rows;
  32. /// A list of rows where the fields are paired to column names.
  33. ///
  34. /// This property is lazily constructed by looping over
  35. /// the rows and columns present in the other two properties.
  36. @property (nonatomic, readonly, nullable) NSArray<NSDictionary<NSString *, id> *> *keyedRows;
  37. @end
  38. NS_ASSUME_NONNULL_END