Commit Graph

11 Commits

Author SHA1 Message Date
thislooksfun 6d27a7b86a Add modifyValue(_:,forKey:)
This adds and implements `open func modifyValue(_ v: Any?, forKey k: String) -> Any` to the `StORM` class.
The intent of this addition is to allow base classes to optionally change the data sent to the database. For example, I am using it to properly handle `Optional`s and the `Date` class in PostgreSQL as follows:
```swift
override func modifyValue(_ val: Any, forKey k: String) -> Any {
	var v = val
	if let o = val as? OptionalProtocol {
		if o.isSome() {
			v = o.unwrap() // not-nil
		} else {
			return ""  // nil
		}
	}
	// After this point, v is guarenteed to not be optional or nil
	
	if let d = v as? Date {
		return d.timestamptz
	}
	
	return v
}
```
The implementations of `OptionalProtocol` and `timestamptz` are irrelevant for this pr.

The `forKey` parameter is there in case someone wants to switch based on name, not on value.

The name is just a placeholder, so feel free to change it if you think of something better.
2017-08-10 00:48:39 -05:00
Jonathan Guthrie dde705a0a9 Adding support for storing [String] as comma delimited strings 2017-04-06 16:26:40 -04:00
Jonathan Guthrie 2a3e52b7a5 Doc Comments! 2016-12-07 15:16:02 -05:00
Jonathan Guthrie a2e274276b Add asDataDict, add filter for varnames with _ 2016-12-02 18:54:40 -05:00
Jonathan Guthrie b5a7dda2ea adding support for json encoded objects 2016-11-11 14:49:05 -05:00
Jonathan Guthrie f711b873f8 adding var StORMdebug 2016-10-20 10:14:58 -04:00
Jonathan Guthrie 54d3e15efb add internal_ column exclusion 2016-10-18 10:20:27 -04:00
Jonathan Guthrie 500c302c05 add keyIsEmpty, create, asData, change cols to return array not dict
add not implemented to error
2016-10-06 10:19:16 -04:00
Jonathan Guthrie 29c4a71dc3 add errorMsg property 2016-10-05 15:15:07 -04:00
Jonathan Guthrie 0e7288c2ba adding start of introspection 2016-10-05 10:31:08 -04:00
Jonathan Guthrie 2a0cc5e27b updating naming so it's consistent 2016-09-30 16:47:58 -04:00