Code Monkey home page Code Monkey logo

Comments (16)

1amageek avatar 1amageek commented on June 11, 2024

@SebastianBO You need to explain the detailed situation.

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

Sorry,
Latest Xcode/Pring version.

The model is "Modelable" and yet I get the error, Object' does not conform to protocol 'Modelable'.
Tried a lot of various solutions, what am I missing?
Thanks for the great work.

  1. Get documents
let document: Document<Model> = Document("DOCUMENT_ID")
document.get { (document, error) in
   print(document.data)
}
  1. Collection Reference
    let query: DataSource<Document<Item>>.Query = DataSource.Query(Firestore.firestore().collectionGroup("items")) let dataSource = DataSource(reference: query)

from ballcap-ios.

1amageek avatar 1amageek commented on June 11, 2024

Thank you for using Pring.
In this library, Document and Model are separated.

Modelable is a Protocol for defining a Model.
Object has Model as a property.

https://github.com/1amageek/Ballcap-iOS#scheme


Any struct that conforms to Modelable & Codable can be handled byDocument <Model>.
Document is a class created by inheriting Object.

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

Been trying to solve this over the weekend, with your updated scheme and instructions. It would be nice with a working example of subcollections and retrieve a specific document

from ballcap-ios.

1amageek avatar 1amageek commented on June 11, 2024

@SebastianBO

let documentReference: DocumentReference = firestore.document("YOUR_PATH")
let doc: Document<Model> = Document(documentReference)
Document<Model>.get(documentReference: documentReference) { document, error

}

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

Even more confusing

from ballcap-ios.

1amageek avatar 1amageek commented on June 11, 2024

@SebastianBO
I don't know what you want to understand.
You need to prepare sample code and a reproducible environment.

Use Document

let documentReference: DocumentReference = firestore.document("YOUR_PATH")
let doc: Document<Model> = Document(documentReference)
Document<Model>.get(documentReference: documentReference) { document, error

}

Use Class that inherits Object

let documentReference: DocumentReference = firestore.document("YOUR_PATH")
let user: User = User(documentReference)
// get from document ref
User.get(documentReference: documentReference) { user, error

}

// get from document id
User.get(id: "USER_ID") { user, error

}

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

Agree, sorry.

  1. Sub Collection as DataSource - not getting it to work in SwiftUI
  2. Retrieve specific document from DB (User) guess it's answered above
  3. Create/Save a document with a specific ID.

Where can I donate to this project?

from ballcap-ios.

1amageek avatar 1amageek commented on June 11, 2024

@SebastianBO
Can you publish part of your code with gist? It would be better for me to see it.

from ballcap-ios.

1amageek avatar 1amageek commented on June 11, 2024

@SebastianBO

Sub Collection as DataSource - not getting it to work in SwiftUI
https://github.com/1amageek/Ballcap-iOS/blob/master/README.md#your-custom-object

Create/Save a document with a specific ID.
https://github.com/1amageek/Ballcap-iOS/blob/master/README.md#initialization

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

Thank you a lot, very appreciated! I'll come back with results if interested

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

let uid = Auth.auth().currentUser!.uid let document: Document<User.Model> = Document(id: uid) document.save()
This saves it to "document collection"
and not override class var name: String { "users" } collection

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

Screenshot 2019-12-12 at 14 44 53

from ballcap-ios.

1amageek avatar 1amageek commented on June 11, 2024

@SebastianBO What version are you using?
If it's happening in the latest version, it's a bug, so please describe the code that can be reproduced with a new issue.

I need to fix it.

from ballcap-ios.

SebastianBO avatar SebastianBO commented on June 11, 2024

It's the latest version.
Just create a document with a specific ID gives this results.

from ballcap-ios.

1amageek avatar 1amageek commented on June 11, 2024

@SebastianBO

Thank you.

I'm testing, but that doesn't happen.
Publish a repository that can be reproduced.

https://github.com/1amageek/Ballcap-iOS/blob/master/BallcapTests/DocumentTests.swift#L61
https://github.com/1amageek/Ballcap-iOS/blob/master/BallcapTests/DocumentTests.swift#L201

スクリーンショット 2019-12-18 16 19 13

from ballcap-ios.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.