remult / remult Goto Github PK
View Code? Open in Web Editor NEWFull-stack CRUD, simplified, with SSOT TypeScript entities
Home Page: https://remult.dev
License: MIT License
Full-stack CRUD, simplified, with SSOT TypeScript entities
Home Page: https://remult.dev
License: MIT License
I would like to see the use of _null
added to the documentation.
Additional context
I found the IsNull
and IsNotNull
methods in FilterSerializer.ts
. These are really handy. Documenting them here would be fantastic.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Is your feature request related to a problem? Please describe.
I prefer to use JSDoc (no build :P).
Describe the solution you'd like
Use remult with regular, simple js
Describe alternatives you've considered
Nothing - I prefer not using TS
Additional context
https://gils-blog.tayar.org/posts/jsdoc-typings-all-the-benefits-none-of-the-drawbacks/
Describe the bug
When I write two entities, one nested inside the other, and I restrict a field on the nested entity with includeInApi, I still get the field when requesting the parent entity. It doesn't show when requesting the nested entity directly.
To Reproduce
Steps to reproduce the behavior:
@Entity("products", {
allowApiCrud: true
})
export class Product {
@Fields.uuid()
id!: string;
@Fields.string()
title = 'Product Title';
@Fields.integer({includeInApi: false})
stock = 0;
}
@Entity("orderItems", {
allowApiCrud: true
})
export class OrderItem {
@Fields.uuid()
id!: string;
@Field(() => Product)
product!: Product;
@Fields.integer()
quantity = 0;
}
export const api = remultExpress({
entities: [OrderItem, Product],
initApi: async remult => {
const productRepo = remult.repo(Product);
const product = await productRepo.insert({});
const orderItemRepo = remult.repo(OrderItem);
await orderItemRepo.insert({product});
}
});
find()
request (GET) on the orderItems
repo.product
nested inside the orderItem
, including its stock
member.Expected behavior
If the stock
field is restricted, it shouldn't appear in the nested product
when querying the orderItems
.
Additional context
Tried this both with {includeInApi: false}
and {includeInApi: "admin"}
(with no actual admin user), same behavior.
The issue
I 've added GraphQL as in the docs (using a forked crm-demo) but GraphQL fails with "errors": [{ "message": "remult object was requested outside of a valid context, try running it within initApi or a remult request cycle",....
when requesting contacts
.
To Reproduce
Clone & checkout this branch https://github.com/anodynos/crm-demo/tree/poc/graphql && npm i
The graphql code in copied from example to server/index.ts
. I've also bypassed getUser: (req) => req.session!['user'],
on server/api.ts
and replaced it with static function returning the user, as that was crushing also with GraphQL
Run and open http://localhost:3002/api/graphql
Execute query { contacts { firstName } }
Expected behavior
Should return results, just like http://localhost:3002/api/contacts does or other entities on GraphQL.
Instead it returns this:
{
"errors": [
{
"message": "remult object was requested outside of a valid context, try running it within initApi or a remult request cycle",
"locations": [
{
"line": 33,
"column": 7
}
],
"path": [
"contacts"
]
}
],
"data": {
"contacts": null
}
}
Desktop (please complete the following information):
Hello, any solution for file uploading and stream files via API?
Angular dependencies, they're not listed as dev dependencies as far as I can tell
Hello guys, I have a problem with deploy to heroku, can't find postgres folder. Where should it be?
2022-07-22T13:38:22.815092+00:00 app[web.1]: > node dist/server/
2022-07-22T13:38:22.815093+00:00 app[web.1]:
2022-07-22T13:38:22.973755+00:00 app[web.1]: node:internal/modules/cjs/loader:488
2022-07-22T13:38:22.973757+00:00 app[web.1]: throw e;
2022-07-22T13:38:22.973757+00:00 app[web.1]: ^
2022-07-22T13:38:22.973757+00:00 app[web.1]:
2022-07-22T13:38:22.973758+00:00 app[web.1]: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './postgres' is not defined by "exports" in /app/node_modules/remult/package.json
2022-07-22T13:38:22.973759+00:00 app[web.1]: at new NodeError (node:internal/errors:371:5)
2022-07-22T13:38:22.973759+00:00 app[web.1]: at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
2022-07-22T13:38:22.973760+00:00 app[web.1]: at packageExportsResolve (node:internal/modules/esm/resolve:731:3)
2022-07-22T13:38:22.973760+00:00 app[web.1]: at resolveExports (node:internal/modules/cjs/loader:482:36)
2022-07-22T13:38:22.973760+00:00 app[web.1]: at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
2022-07-22T13:38:22.973761+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
2022-07-22T13:38:22.973761+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-07-22T13:38:22.973762+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-07-22T13:38:22.973762+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-07-22T13:38:22.973762+00:00 app[web.1]: at Object.<anonymous> (/app/dist/server/api.js:9:20) {
2022-07-22T13:38:22.973763+00:00 app[web.1]: code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
2022-07-22T13:38:22.973763+00:00 app[web.1]: }
2022-07-22T13:38:23.126667+00:00 heroku[web.1]: Process exited with status 1
2022-07-22T13:38:23.166298+00:00 heroku[web.1]: State changed from starting to crashed
This is my local implementation, I wish it was in the api.
export async function deleteAll(repo: Repository,
where?: EntityFilter) {
for (const clientRow of await repo.find({ where })) {
await repo.delete(clientRow);
}
}
To Reproduce
Steps to reproduce the behavior:
deno task start
Expected behavior
App should load successfully - as with v0.15.
Hello again, I have a tricky problem to solve. I have 2 entities (Services and Tiers), depends on docs I created them like below:
Services
import { Tier } from './/Tier';
import { Allow, Entity, Fields, IdEntity } from "remult";
@Entity("services", {
allowApiRead: true,
allowApiUpdate: Allow.authenticated,
allowApiDelete: Allow.authenticated,
allowApiInsert: Allow.authenticated,
})
export class Service {
@Fields.uuid()
id!: String;
@Fields.string()
title!: string;
@Fields.string()
description!: string;
@Fields.string()
image!: string;
@Fields.number()
price!: number;
@Fields.object<Tier>((options, remult) => {
options.serverExpression = async (tier) => {
remult.repo(Tier).find({where: {serviceId: tier.id}});
}
})
@Fields.boolean()
active!: boolean;
@Fields.boolean()
featured!: boolean;
}
Tiers
import { Allow, Entity, Field, Fields, IdEntity } from "remult";
@Entity("tiers", {
allowApiRead: true,
allowApiUpdate: Allow.authenticated,
allowApiDelete: Allow.authenticated,
allowApiInsert: Allow.authenticated,
})
export class Tier extends IdEntity {
@Fields.string()
serviceId!: string;
@Fields.string()
name!: string;
@Fields.number()
price!: number;
}
Tiers are childs for Services, I'm using Angular and have no idea how to join them. Is there any solution for that? How can I appeal to Services via Tiers and vice versa?
remove setDataProvider
remove _dataSource
Add get to SqlDatabase - that'll get the SqlDatabase
And for mongo
And for knex
etc...
In other data providers( postgres for example) if we add a column to the entity, it is automatically added to the table , if auto create tables is set to true.
In web sql it doesn't
That way we can control in the endpoint which entities may be created in the create data provider
First of all, I would like to thank you for this great library. Using multiple ViewModels for the same entity is a common scenario for web applications (Different validation sets for different operations, hiding and exposing some properties depending on the situations, etc.). I wonder how remult handles this kind of scenario. It would be nice if you can redirect me to a sample or documentation.
Describe the bug
A clear and concise description of what the bug is.
the default value of apiBaseUrl
= '/api'; is problematic when using baseURL='/xx/index.html'
On the other hand, if it's set to api
it fails if you have nested routes in the app. (ie '/customersPage/1')
We should find some solution for the default value of apiBaseUrl that will support both nested routes, and apps that reside in a virtual directory.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Now i go to "Refactor from Front-end to Back-end" of Tutorial remult for Next.js at link:
https://remult.dev/tutorials/react-next/backend-methods.html#set-all-tasks-as-un-completed
when npm run dev: error is folow in console:
{
message: "can't use static remult in this environment, async_hooks
were not initialized",
stack: [
"Error: can't use static remult in this environment, async_hooks
were not initialized",
' at RemultAsyncLocalStorage.getRemult (/home/quangtynu/remult-nextjs-app/node_modules/remult/server/expressBridge.js:114:19)',
' at RemultProxy.remult_proxy_1.remult.remultFactory (/home/quangtynu/remult-nextjs-app/node_modules/remult/server/expressBridge.js:96:54)',
' at RemultProxy.repo (/home/quangtynu/remult-nextjs-app/node_modules/remult/src/remult-proxy.js:20:32)',
' at setAll (webpack-internal:///(api)/./src/shared/TasksController.ts:19:69)',
' at myServerAction.originalMethod (/home/quangtynu/remult-nextjs-app/node_modules/remult/src/server-action.js:197:114)',
' at myServerAction. (/home/quangtynu/remult-nextjs-app/node_modules/remult/src/server-action.js:146:71)',
' at step (/home/quangtynu/remult-nextjs-app/node_modules/tslib/tslib.js:144:27)',
' at Object.next (/home/quangtynu/remult-nextjs-app/node_modules/tslib/tslib.js:125:57)',
' at fulfilled (/home/quangtynu/remult-nextjs-app/node_modules/tslib/tslib.js:115:62)',
' at processTicksAndRejections (node:internal/process/task_queues:96:5)'
],
url: '/api/setAll',
method: 'POST'
}
I using Ubuntu on WSL2.
any idea about async_hooks?
Describe the bug
The dbName
option of a field, works great in postgres and sql - but doesn't work when it comes to json db.
To Reproduce
Consider the following class:
@Entity("tasks", {
allowApiCrud: true
})
export class Task {
@Fields.uuid()
id!: string;
@Fields.string({dbName:'theTitle')
title = '';
@Fields.boolean()
completed = false;
}
When the data is stored in the tasks.json
file, the second field is stored as title
and not theTitle
[
{
"id":"a",
"title":"Task a"
}
]
Expected behavior
it should be called theTitle
in the json file:
[
{
"id":"a",
"theTitle":"Task a"
}
]
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
I already set remult.apiClient.httpClient = http (angular HttpClient) in angular AppModule constructor
and I set an angular interceptor also
but in remult repo operation throw error, I can't get any error intercept message
just can do try catch get the error
I want easily to handle the error in one way
another idea?
thanks
Please change beforeClose to beforeClosed in radweb\projects\angular\src\angular\remult-core.module.ts line 78.
I'd also like to be able to potentially make pull requests for this project in the future.
But at the moment i get 403, not sure if this is normal or not.
Thanks
Create a version of the Todo App tutorial for Nuxt and/or a GitHub repo with an example project we can share with the community.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
In the case of an entity that it's unique identifier is comprised by more than one column, today one needs to use the Compound id field:
@Entity<theTable>('', {
id: t => new CompoundIdField(t.a, t.b)
})
class theTable extends EntityBase {
@Fields.string()
a: string;
@Fields.string()
b: string;
@Fields.string()
c: string;
}
Describe the solution you'd like
A clear and concise description of what you want to happen.
I think that the CompoundIdField is a complexity that can be avoided by allowing id to return more than one column - something like:
@Entity<theTable>('', {
id: t => [t.a, t.b]
})
class theTable extends EntityBase {
@Fields.string()
a: string;
@Fields.string()
b: string;
@Fields.string()
c: string;
}
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Describe the bug
I'm trying to use remult in my project. I'd like to use ES modules.
I get the following error:
(node:2822177) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/me/ts-app-esm-template/node_modules/remult/esm/remult-express.js:1
import * as express from 'express';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
Node.js v18.3.0
See GuillaumeDesforges/ts-app-esm-template#1
To Reproduce
Steps to reproduce the behavior:
WARNING requires node >= 18.x
yarn install
yarn build
node api
Expected behavior
The import should not fail.
Describe the bug
When trying to insert some data using mysql data provider and an entity with autoIncrement() data type, it will throw an error, but is successfully inserted into the database.
.returning() is not supported by mysql and will not have any effect.
Error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [id] query: where `id` = ?
at QueryCompiler_MySQL.toSQL (D:\Projects\App\remult\remult-test\node_modules\knex\lib\query\querycompiler.js:110:13)
at compileCallback (D:\Projects\App\remult\remult-test\node_modules\knex\lib\formatter\formatterUtils.js:13:19)
at rawOrFn (D:\Projects\App\remult\remult-test\node_modules\knex\lib\formatter\wrappingFormatter.js:225:7)
at QueryCompiler_MySQL.whereWrapped (D:\Projects\App\remult\remult-test\node_modules\knex\lib\query\querycompiler.js:1084:17)
at QueryCompiler_MySQL.where (D:\Projects\App\remult\remult-test\node_modules\knex\lib\query\querycompiler.js:573:34)
at D:\Projects\App\remult\remult-test\node_modules\knex\lib\query\querycompiler.js:133:40
at Array.forEach (<anonymous>)
at QueryCompiler_MySQL.select (D:\Projects\App\remult\remult-test\node_modules\knex\lib\query\querycompiler.js:132:16)
at QueryCompiler_MySQL.toSQL (D:\Projects\App\remult\remult-test\node_modules\knex\lib\query\querycompiler.js:73:29)
at Builder.toSQL (D:\Projects\App\remult\remult-test\node_modules\knex\lib\query\querybuilder.js:83:44)
To Reproduce
Steps to reproduce the behavior:
import { Entity, Fields } from "remult";
@Entity("tasks")
export class Task {
@Fields.autoIncrement()
id!: number;
@Fields.string()
title = "";
}
let task = await remult.repo(Task).insert({ title: "Test Task" });
console.log("CREATE", task);
Expected behavior
Expected to return object of the task including its id
Desktop (please complete the following information):
Additional context
Tested on postgres and jsonprovider, it works well.. only error with mysql2
Either create it with a flag or on demands
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
In have a Backend method where it's allowed
options determines who is allowed to run it:
@BackendMethod({ allowed: Allow.authenticated })
In the frontend, I would like to display the button only to users who can run the BackendMethod.
Today the only way I can do that, requires me to repeat myself and write:
remult.isAllowed(Allow.authenticated)
Describe the solution you'd like
A clear and concise description of what you want to happen.
I would prefer to have a single source of truth, meaning that if I defined the rule once in the backend method, I should be able to query it using something like:
remult.isAllowed(TasksController.setAll)
and that it'll take into consideration the allowed: AllowAuthenticated
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
remult supports the ActiveRecord
pattern, but most if not all of the docs do not reflect it.
Describe the solution you'd like
An article outlining the usage of ActiveRecord
, pros and cons etc... would be useful
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Add docs on how to make complex joins and queries, using the underlying database
based on:
https://www.facebook.com/groups/jsisrael/posts/5320208751356093/?comment_id=5322650931111875
Describe the bug
A clear and concise description of what the bug is.
When I insert multiple rows using remult.repo().insert
for an entity with an autoIncrement
column - these rows are not inserted in the correct order.
To Reproduce
Steps to reproduce the behavior:
@Entity('entityWithAutoId')
class entityWithAutoId extends EntityBase {
@Fields.autoIncrement()
id: number;
@Fields.string()
name: string;
}
...
await remult.repo(entityWithAutoId).insert([
{ name: 'a' },
{ name: 'b' },
{ name: 'c' }
]);
Expected behavior
A clear and concise description of what you expected to happen.
[ { id: 1, name: 'a' },
{ id: 2, name: 'b' },
{ id: 3, name: 'c' }]
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Create a version of the Todo App tutorial for Svelte (or SvelteKit) and/or a GitHub repo with an example project we can share with the community.
Originally posted by mariolorente May 24, 2022
It would be awesome if you can subscribe to any model/list. For me it would a no brainer to use this.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Unhandled Runtime Error
ReferenceError: hideCompleted is not defined
Source
pages/index.tsx (10:24) @ fetchTasks
8 | limit: 20,
9 | orderBy: { completed: "asc" },
10 | where: { completed: hideCompleted ? false : undefined }
| ^
11 | });
12 | }
13 |
Call Stack
eval
pages/index.tsx (19:4)
Show collapsed frames
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Describe the bug
The ErrorInfo
's modelState
property includes references to the objects fields, but also to the object's methods.
To Reproduce
Consider the following class:
class person{
firstName='';
lastName='';
getFullName(){
return this.firstName+' '+this.lastName
}
}
Expected behavior
A clear and concise description of what you expected to happen.
When I use the ErrorInfo
type with it, it should only include firstName and lastName - and not - getFullName
Screenshots
If applicable, add screenshots to help explain your problem.
The getFullName
shouldn't appear in the intelisense
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.