Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add finder methods to builder #34

Merged
merged 1 commit into from
Feb 10, 2024
Merged

Add finder methods to builder #34

merged 1 commit into from
Feb 10, 2024

Conversation

MrLeebo
Copy link
Owner

@MrLeebo MrLeebo commented Feb 10, 2024

Sample Schema

model Product {
  id     String  @id @default(auto()) @map("_id") @db.ObjectId
  name   String
  photos Photo[]

  thumbnailUrl String
  previewUrl   String
}

Find a model by name

const product = builder.findByType("model", { name: "Product" })
expect(product).toHaveProperty("name", "Product")

Find all fields by pattern

const [thumbnailUrl, previewUrl] = builder.findAllByType("field", { name: /Url/, within: product.properties })
expect(thumbnailUrl).toHaveProperty("name", "thumbnailUrl")
expect(previewUrl).toHaveProperty("name", "previewUrl")

@MrLeebo MrLeebo merged commit 4865f0c into main Feb 10, 2024
9 checks passed
@MrLeebo MrLeebo deleted the finder-methods branch February 10, 2024 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant