Skip to content
This repository was archived by the owner on Jan 3, 2021. It is now read-only.

Commit f75cb14

Browse files
committed
Docs
1 parent 1883fe3 commit f75cb14

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Sources/Meow/Model.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public protocol BaseModel : SerializableToDocument, Convertible, Identifyable {
8181

8282
/// A list of all dot-notated keys that are a reference to a model and their referenced type
8383
///
84-
/// The previous models chain is used to prevent infinite recursion
84+
/// - parameter previousModels: The previous models chain is used to prevent infinite recursion. Whenever `recursiveKeysWithReferences` is queried, all types found will also be queried for their `recursiveKeysWithReferences` recursively.
85+
/// - throws: When the recursion triggers a higher-level model that has been accessed earlier in the chain
8586
static func recursiveKeysWithReferences(chainedFrom previousModels: [BaseModel.Type]) throws -> [(String, BaseModel.Type)]
8687

8788
/// Will be called when the Model will be deleted. Throwing from here will prevent the model from being deleted.
@@ -127,7 +128,10 @@ extension Model {
127128
return try closure(VirtualInstance(keyPrefix: "", isReference: false))
128129
}
129130

130-
/// A list of all dot-notated keys that are a reference to a model
131+
/// A list of all dot-notated keys that are a reference to a model and their referenced type
132+
///
133+
/// - parameter previousModels: The previous models chain is used to prevent infinite recursion. Whenever `recursiveKeysWithReferences` is queried, all types found will also be queried for their `recursiveKeysWithReferences` recursively.
134+
/// - throws: When the recursion triggers a higher-level model that has been accessed earlier in the chain
131135
public static func recursiveKeysWithReferences(chainedFrom previousModels: [BaseModel.Type]) throws -> [(String, BaseModel.Type)] {
132136
let directKeys: [(String, BaseModel.Type)] = try Self.Key.all.flatMap { key in
133137
guard let type = key.type as? BaseModel.Type else {

Sources/Meow/VirtualVariable.swift

+8
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ public protocol VirtualModelInstance {
1111
///
1212
/// - parameter keyPrefix: The keyPrefix is prefixed to all query keys as returned from the VirtualInstance, for the
1313
/// purpose of being able to embed structs.
14+
/// - parameter isReference: The isReference is true when the VirtualInstance is a referenced VirtualInstance rather than a directly queried VirtualInstance.
15+
/// This is used to determine the kind and method to to create a query for data accessed from this VirtualInstance
1416
init(keyPrefix: String, isReference: Bool)
1517

18+
/// The prefix of all the queries generated from the VirtualInstance
1619
var keyPrefix: String { get }
20+
21+
/// If this VirtualInstance is referenced from a higher-level query
1722
var isReference: Bool { get }
1823
}
1924

2025
extension VirtualModelInstance {
26+
/// Appends a dot (`"."`) to the keyPrefix if the VirtualInstance is a reference.
27+
///
28+
/// This allows keys to be queried in a $match stage after a $lookup stage has been added.
2129
public var referencedKeyPrefix: String {
2230
if isReference {
2331
return keyPrefix + "."

0 commit comments

Comments
 (0)